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: 

Case Structures

Solved!
Go to solution

Hello, I am working on a school project. I have a while loop that and calculates BMI and inserts it in an array 200 times. I need to create 6 categories for BMI, such if (if BMI=0, Catergory = NA, if BMI< 18.5, Catergory= underweight, if BMI>=18.5 && BMI<=24.9, Category = Healthy, etc). How do I do this using case structure? Cannot figure out a way. I have BME categories stored as Enums

0 Kudos
Message 1 of 26
(1,874 Views)

I believe that you may want to rethink your approach. 

 

Since this is homework I'll only pass in a reading assignment and a hint.  You have a monotonic array of thresholds... read the descriptions of the functions on the Array Palette an see if that inspires you.  

 

(And turn off quick drop until you have learned the basic Palette features!.... it's like trying to learn elementary arithmetic by using a calculator!)


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 26
(1,853 Views)

I'll help you narrow down a little more.  Specifically study the Threshold 1D Array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 26
(1,820 Views)

@crossrulz wrote:

Specifically study the Threshold 1D Array.


... and then index in an array of strings or wire to your enum. No case structure needed.

0 Kudos
Message 4 of 26
(1,807 Views)

@taras01 wrote:

Hello, I am working on a school project. I have a while loop that and calculates BMI and inserts it in an array 200 times.


Seem redundant to insert it 200 time unless you have 200 different datasets. If the input is an array of 200 datasets, you'll get an array of 200 results. No need to "insert" anything. Since you know the number of iterations before the loop starts, a FOR loop is more appropriate than a WHILE loop.

 

What is the raw data? A 2D array where each row contains mass and height to calculate BMI? An 1D array of BMIs? A text file that needs to be parsed?

 

Typically you will get better help if you would attach a simple VI that contains a typical dataset and your enum, Please do.

0 Kudos
Message 5 of 26
(1,800 Views)

That is SubVI we need to use. It produces 1D array of cluster of 6 elements for each patient and there are 200 of them.

0 Kudos
Message 6 of 26
(1,796 Views)

@taras01 wrote:

That is SubVI we need to use.


What is?

 

So just autoindex on your array, unbundle and process the 6 elements for each subject, then get the array of results at the end.

 

What are the 6 elements per cluster? Are some of them inputs for the calculation and some results to be updated? Is the cluster a typedef?

0 Kudos
Message 7 of 26
(1,793 Views)
Spoiler
Yeah, that's exactly what I did.  I unbundled by name, calculated the BMI for all patients, and used case structure to set the BMI to 0 if the pt is a child, outputting an array of 200 BMI's.

All cluster elements are outputs from the subVI. I need to add an element of BMI to the original cluster and an element of the category of BMI (healthy, obese, etc). So for example, for pt one, the SubVI produces (pt number, age, weight, height, gender) after the code each pt cluster should have (pt number, age, weight, height, gender, +BMI, + BMI category). I am stuck on how to categorize into categories and then how to add BMI and BMI categories to the original 1D array of clusters.
0 Kudos
Message 8 of 26
(1,768 Views)

And also, not sure if Threshold 1D array can be used here. I am also trying to use the nested case structures, but not sure how to set the conditions in that setup. 

0 Kudos
Message 9 of 26
(1,766 Views)

@taras01 wrote:

And also, not sure if Threshold 1D array can be used here.


Why not?

 


@taras01 wrote:

I am also trying to use the nested case structures, 


No, please don't!

 

0 Kudos
Message 10 of 26
(1,757 Views)