From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Beginner help with arrays.

Solved!
Go to solution

Hi,

 

I am tryng to program a VI for school that imports a spreadsheet of 16 student's grades, and build arrays with their final averages, and letter grades. I am having some trouble figuring out how to efficiently get the final averages asociated with a letter grade, based on the final average, ie. between 80 & 89  = B. I started to use case structures, but I think I would need to make a case for every student, and then cases for each grade within those cases. I am hoping there is a better way.

I have attached the VI & .txt file to be imported. I would appreciate any help or advice!

 

Thanks so much,

 

George 

Download All
0 Kudos
Message 1 of 13
(4,485 Views)

To fix the grades case concern you can do something like below.  I feel like with a for loop you would be able to do away with a lot of the code in the middle where you are doing some dividing and subtracting.  Using the loop iteration number from the for loop you could put all that code into one for loop.

 

Grades.png



-Matt
0 Kudos
Message 2 of 13
(4,480 Views)

Hi Wolleee,

 

I am not sure I am following you. If the output of the "build array" contains each student's final numerical average, how can the "for loop" iterations determine which case should be selected depending on the final average? Also, how will it help to produce another array containg the final letter grades?

 

Sorry if I'm missing something simple here.

 

I appreciate the help.

 

George

0 Kudos
Message 3 of 13
(4,470 Views)

I can't open your VI but this is all you should need to get the averages and the letter grades for all of the students in the text file. 

 

Example_VI_BD.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 13
(4,457 Views)

Do something like this.  I wasnt sure what you were doing, but i recreated it using a loop. You can also see in the for loop that i use case logic to select which letter grade to select for the grade percentage

 

Grades.png



-Matt
0 Kudos
Message 5 of 13
(4,452 Views)

Your VI is way too complicated and not scalable.

 

The ideas using the ranges for the case structure may not be ideal.  Suppose you have a 69.5?  Should that be a D?  Or do you want to round that up to 70 and make it a C?  Using case structure ranges does the latter.

 

Wollee, please post VI's that can be opened in the same version the original poster used.  He used LV 15. You posted a LV 16 snippet.  Also, when indexing out an array where you want all the elements in order, you are wasting your time filling in all the index constants.  Index Array by default gives you element 0, 1, 2, 3, .....

 

Download All
0 Kudos
Message 6 of 13
(4,424 Views)

Hi Matt,

 

Thanks for the clarification. That code works, bur I can only see the very first letter grade. How could I generate an array with all 16 grades in it from there?

 

Thanks,

George

0 Kudos
Message 7 of 13
(4,399 Views)

Hi RavensFan,

 

I didn't realize that I didn't need the constants for the index array, makes sense though that it would go in order.

 

What you have there is just wow! You just put that together now!? It's taken me hours to get as far as I did. It is very humbling to see something like that done so quickly. I have barely scratched the surface of LV! I am impressed with how simple your code looks, and it does exactly wehat I needed. I have not used a few of those functions yet, but I can follow along for the most part. I looked for a function that would give me the numerical averages, but obviously looked over the mean function you used. I was going to save some of my bulky code as subvi's but you have used functions that would make that unnecessary.

 

Thanks very much!

 

George

 

0 Kudos
Message 8 of 13
(4,389 Views)

RavensFan,

 

I deleted the constants for the index arrays, but the entire arrays were not populated. I only wanted to index the columns and not the rows. Is there another way to do that without the constants?

 

Thanks again!

 

George

0 Kudos
Message 9 of 13
(4,385 Views)

If you want to index all the columns, you will  need to leave one constant 0 wired into the column input of the first item. Completely unwired Index Array on a 2-D array defaults to rows starting at row 0.  Wiring a 0 into the first column input will default to all columns starting with column 0.  You won't need any of the other indices wired up in either case.

0 Kudos
Message 10 of 13
(4,364 Views)