LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array into a case statement

Solved!
Go to solution

@gleatd01 wrote:

Also, your saying I need to go more along this route?


No. According to the problem description, you have three arrays as input. All have the same length (not sure why they don't specify a 2D array where the columns are exam# and rows are students).

 

So do the following:

 

  1. Use a FOR loop to create the three 1D arrays, nothing else. Now you have simulated data. (Later you can easily modify the program to read scores e.g. from a database or file without changing analysis code.
  2. Use a second FOR loop, autoindexing on all three array, i.e. processing the data for one student and creating a bundle with average, rank, letter grade, and a dummy class rank (e.g. -1). Use proper weighting to calculate the average of the three exams.
  3. Autoindex that cluster on the right loop boundary to create an array of such cluster.
  4. Sort this cluster using "sort 1D array". Note that arrays of clusters are sorted according to cluster order, so your output will be sorted primarily by course average. Since the lowest score is on top, reverse the array to have the highest score on top.
  5. Autoindex on a new FOR loop and replace the dummy class rank with [i]+1 to get the real class rank in the final array of clusters.

 

Note that the exercise is relatively flawed. You probably also want to retain the student ID, i.e. keep the original array index also in a cluster element so we can identify the student for each score in the final output. As I said, you also need to decide what should happen if the score is in an undefined interval, e.g ]79..80[. It is possible that average scores are rounded to integers, so you need to know the rounding rules and adjust accordingly.

0 Kudos
Message 11 of 15
(1,212 Views)
Solution
Accepted by topic author gleatd01

@gleatd01 wrote:

... do you happen to know of a decent tutorial on threshold arrays?


Have you tried the help for the function? Have you tried searching the forum here? You might have come across this one, but there are many more examples.

 

 

 

Here's how it could be implemented in your problem. Try to figure out the rest of the code for some ideas, but do your own version. Note that most code subtleties have their reason so try to fully understand them. You need many adjustments, because it does not match all original problem requirements!

 

altenbach_0-1615752536774.png

 

0 Kudos
Message 12 of 15
(1,204 Views)

My examples seem to always be grey, might be missing something. But I did figure out the problem. I created an array for each then I weighted the grades and summed them and got the appropriate weighted grade. Figured out how to make cases with something other than true false by right clicking the border and was all set.

Thank you all. Just to figure out how to re enable examples.

0 Kudos
Message 13 of 15
(1,152 Views)

Definitely need to look more into named bundles, I tried to add the rank at the end after sorting and had to unbundle the cluster to add the ranks. Also can you only sort by the first column?

0 Kudos
Message 14 of 15
(1,148 Views)

@gleatd01 wrote:

Definitely need to look more into named bundles, I tried to add the rank at the end after sorting and had to unbundle the cluster to add the ranks. Also can you only sort by the first column?


You can sort any way you want, you just need to (at least temporarily) arrange the data the way you want it sorted. It is especially simple if you only want to sort by exactly one cluster element (example from here). 

 

0 Kudos
Message 15 of 15
(1,145 Views)