LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array into a case statement

Solved!
Go to solution

I have an assignment where I generate three random graded in a for loop then outside the loop average them. I am trying to have this average entered into a case statement to determine the letter grade however I keep getting an index array error. I want to only have dbls output from the for loop (wired into a bundle) for collection. What am I doing wrong? Or what function am I missing? Simply converting an array to a dbl would be enough of an answer for me.

0 Kudos
Message 1 of 15
(3,736 Views)

@gleatd01 wrote:

What am I doing wrong? Or what function am I missing? Simply converting an array to a dbl would be enough of an answer for me.


We don't know.  You didn't post a VI for us to see what you actually did.

0 Kudos
Message 2 of 15
(3,722 Views)

Here you go, please help. It would be greatly appreciated.

0 Kudos
Message 3 of 15
(3,691 Views)

You are NOT using a case structure, that's a stacked sequence. (Not sure where you found that, because it is not in the palette). You don't need the formula node for this.

 

(You are seem a bit confused with scalars and arrays. Have you done some simple LabVIEW tutorials yet?)

0 Kudos
Message 4 of 15
(3,675 Views)

I have been working through Learning with LabView for an Online course we are on chapter 6 now. May have missed something.

0 Kudos
Message 5 of 15
(3,664 Views)

I see the following problems:

 

  • You are generating 60 random numbers between 0 and 100 and are creating 20 averages.
  • Your blue diagram constants should probably be orange.
  • So you have an array of 20 averages but are only creating a single letter grade. Wouldn't it make more sense to either create 20 letter grades or have only a single scalar average? If all 20 averages are important, why don't you resize the array container in the cluster to show more than one element?
  • Your first comparison in the formula node seems to be wrong. (Assume it operates on a scalar input, remove the (0) and you get either a 1 for anything above 59 and a 2 otherwise. None of the others (3, 4, 5) results can ever appear.) 

I think you might have simplified the problem description and left out too many details. Can you show us the full text of the assignment? In any case, this is a basic beginner problem and the solution should be significantly simpler that what you were doing.

0 Kudos
Message 6 of 15
(3,642 Views)

D6.2 is the problem I am working on.

20210314_104813-smaller

 

20210314_104823-smaller

Download All
0 Kudos
Message 7 of 15
(3,628 Views)

(In the meantime, also try to learn how to rotate and crop photographs. We are NOT dealing with 12MB of information here.)

 

altenbach_0-1615739658969.png

 

 

 

As I suspected, you need to create a letter grade for each of the 20 (or whatever) students, so your control with 20 averages and only one letter grade is insufficient. The book says to to create an array of clusters, where each cluster element contains the information for one student.

 

Note that the book seem to have logical problems too, for example it does not define what should happen if the course average is 79.5%.

 

Done right, the case structure can replace your formula node. In fact there are simple methods to detect ranges using threshold array and an array of limits, then indexing into an array of letters. No case structure or formula node needed.

 

0 Kudos
Message 8 of 15
(3,624 Views)

Thank you altenbach, do you happen to know of a decent tutorial on threshold arrays? Also, it doesn't seem like much information about LabVIEW really exist outside of this site, are any well known tutorial sources around? I may just be failing to provide good keywords in my searches.

 

Thanks

0 Kudos
Message 9 of 15
(3,610 Views)

Also, your saying I need to go more along this route? Time delay is only temporary, wanted to make sure its actually stepping through.

gleatd01_0-1615746251496.png

 

0 Kudos
Message 10 of 15
(3,607 Views)