# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Lab View Help (arrays)

Hi,

I'm struggling to figure out how to take an array and assign a letter grade to the given value. The portion of the assignment I am trying to do right now is:

Determine the country’s “Grade” using the following scale;

A = <= 50 pounds / person
B = >50 & <= 100 pound / person
C = >100 pounds per person

This is what I have so far, the first loop is from the first part of my project and the second loop is what I am trying to do for this current part.

Currently my output only comes out for the first element of the array. Please let me know what I am doing wrong and how to fix it.

Message 1 of 23
(2,751 Views)

## Re: Lab View Help (arrays)

Hi Aman,

It's because you have the "last element" terminal on the output of your for loop. You should change it to "indexing".

Secondly, you can wire the numeric wire directly into the Case Selector of the Case Structure and define which case will be executed under which condition:

https://zone.ni.com/reference/en-XX/help/371361R-01/glang/case_structure/

You can check even the example how to use it in Example Finder -> Case Structure - Selector Data Types

_______________________________________________________________

-Patrik
CLA || CTA
If it helps - Kudo it, if it answers - Mark As Solution
Message 2 of 23
(2,721 Views)

## Re: Lab View Help (arrays)

@AmanAman wrote:

Hi,

I'm struggling to figure out how to take an array and assign a letter grade to the given value. The portion of the assignment I am trying to do right now is:

Determine the country’s “Grade” using the following scale;

A = <= 50 pounds / person
B = >50 & <= 100 pound / person
C = >100 pounds per person

(Sorry, cannot see your VI because I don't have LabVIEW 2021 here. Consider "save for previous" or at least attach a picture)

• What is the input array (numeric array of weights for one country? Array of country&weight clusters where each country can occur multiple times, etc.)
• Is the grade calculated from the average of all weights for each country?
• What is the desired output (One single grade for the current country? A table of countries and grades? etc.)
Message 3 of 23
(2,691 Views)

## Re: Lab View Help (arrays)

Hi,

Thank you for your response. I just changed to output to "indexing" and now I do get multiple elements in my array. However it is only inserting the first element from the array into all the rows. Also I do not understand what you mean by "wire the numeric wire directly into the Case Selector of the Case Structure and define which case will be executed under which condition". I did what I understood from it and wired it accordingly is this correct? the output is the same regardless of the wiring to the case selector

Message 4 of 23
(2,668 Views)

## Re: Lab View Help (arrays)

Floating point numbers cannot be wired to the case selector, only integer numbers can. I also don't have LV 2021 installed so can't look at anything beyond the picture.

Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 5 of 23
(2,663 Views)

## Re: Lab View Help (arrays)

A truncated code image is completely useless (except that it tells us that you have very little experience 🙂 )

Please show the entire code and all cases of case structures! Where's the loop? Where's the tunnel? Where do the wires come from? Where do they go?

Typically you would just threshold into an array of limits, round it correctly, and index into an array containing [A, B, C]. No need for case structures and range functions.

Message 6 of 23
(2,662 Views)

## Re: Lab View Help (arrays)

@Mark_Yedinak wrote:

Floating point numbers cannot be wired to the case selector, only integer numbers can.

Yes, they "can", but the result might not be what's expected 😄

Message 7 of 23
(2,657 Views)

## Re: Lab View Help (arrays)

Expect the unexpected 😄

@Mark_Yedinak, you're right, I didn't notice he's using floating points.

Edit: I saved his VI in version 17, if you want to take a look. (Missing subVI is missing even in original attachment 🙂 )

For the author:
Yes, you have to pass the wire directly into the case selector, but as pointed by Mark, you shouldn't use it with the double data type. Either you can convert the floating-point into the integer or use integers from the beginning if you are working with non-floating-point numbers.
For how to use Case Structure with integers, the link from my first reply and/or the example in the Example Finder should help.

_______________________________________________________________

-Patrik
CLA || CTA
If it helps - Kudo it, if it answers - Mark As Solution
Message 8 of 23
(2,638 Views)
Solution
Accepted by AmanAman

## Re: Lab View Help (arrays)

See if this can give you some ideas. (just a picture, so try to implement it. A good exercise). Note: No case structure! (Some things can be simplified, but start with that)

Message 9 of 23
(2,583 Views)

## Re: Lab View Help (arrays)

This gives the same result but is a bit more obscure. Try to figure out how it works 😄

Message 10 of 23
(2,582 Views)