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.
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.
05-13-2013 09:34 PM - edited 05-13-2013 09:35 PM
Hi, all. I want to compare an array of numbers with 0 first, if they are bigger than zero, we do a simple calulation such as 10+10; if they are smaller than 0, we do another simple calulation such as 10-5; of course it can be realized by the VI i wrote in the attachment, but I wonder if we have any better ways to solve it, maybe only one case structure since we have the exactly same calculation for the same situation. Thanks for any useful suggestions. I have updated a picture just in case if you don't want to download the VI.
Solved! Go to Solution.
05-13-2013 09:50 PM - edited 05-13-2013 10:00 PM
You can search the 1-D boolean Array for a True value. Then the value will be -1 (no trues), 0, 1, 2, or 3 for the index. Hav that drive a single case structure. Where the respective indicator is in each case.
Of course if all the calculations are exactly the same (I assuming 10-5 is just simplified), you can put the calculation outside of the case structure and feed it to the respective cases.
EDIT: You don't need to build an array of zeroes to compare to another array. You can just use a scalar zero. And you don't need that. Just use the >0 primitive.
Actually, I'm not really sure what you are trying to do here. Why do you have different indicators in the false cases and the true cases?
05-13-2013 09:50 PM
See attached.
05-13-2013 09:53 PM
Didn't catch "RavensFan" reply on time. That solution is cleaner.
kas
05-13-2013 10:36 PM
thanks for the fast reply, RavensFan! It is very straightfowd to compare two arrays because i have a lot of troubles with "you have connect two wires with different data type" issue, so now when I write the code, I want to always make them to be the same type. The indicator for individual case structure are different becasue I used a Index Array to get the Ture or False for each comparison. Thanks for your explaintion, and also with KAS's codes, i think I understand this completely. Thank you guys very much.