02-15-2016 05:36 AM
Hello.
I just started using LabVIEW so I'm really sorry if the question seems silly to some of you. But I'm really in need of help.
I'm supposed to make a sub VI that gets an array and gives back TRUE if the function is not decreasing and FALSE if it is decreasing.
I was only able to make a VI that checks every next element and gives answer for every next element (checks if the element is <= than previous) but can't put one answer as the final result.
Can you, please, help me?
02-15-2016 05:43 AM
So every sample must be less than the previous? If you have an array of all of the results (Booleans), then just use OR Array Elements (since TRUE means you are not decreasing) to get a single Boolean. With an OR, if any of the results were TRUE, then the final result is a TRUE.
02-15-2016 06:14 AM - edited 02-15-2016 06:24 AM
I still don't understand how to make this array.
Every time the array of booleans only shows last value on every position.
I'll maybe try to attach a file, because I'm probably making some very stupid mistake, but I can't see it.
EDIT:
Found the sollution, I'm sorry, Now I'm working on the last part.
Thank you for your help. I hope I won't have to ask no more of those silly (for you) questions 🙂
02-15-2016 07:34 AM
No question is silly. Sometimes just asking the question forces you to slow down and, suddenly, the answer is apparent. When I "get stuck" with code that doesn't quite work, I'll frequently find some "innocent bystander" (a colleague or someone with, say, Matlab experience) and explain my problem to them. Usually they'll say "But why do you think this has to be positive?", and I'll say, "Ooooh, I forgot to put in the Absolute Value function ...". There are few things as valuable as "explain your code to someone else" for finding bugs.
Bob Schor
02-15-2016 08:31 AM
Also called Rubber Duck Debugging.
02-15-2016 12:59 PM
If the current element is larger (or equal) than the previous element, and all previous elements have been checked in order in the same way, the current element will also be larger (or equal) than all previous elements. There is no need to create any boolean arrays (extra memory allocations can be expensive for very large arrays). Keep checking in an autoindexing conditional FOR loop and exit early if the test fails. The scalar output that was also wired to the conditional terminal will tell the overall result once the loop has completed.
If you set the comparison and stop condition correclty, the output will be the anwer directly
You are probably using a shift register to compare with the previous. If you initialize it with "-inf", you can autoindex on the array directly.
See if these ideas would simplify your code. 😄
For a more bulletproof subVI, make sure that it correctly handles inputs that are empty arrays or arrays that might contain some elements that are NaN.
02-16-2016 03:02 PM
A very simple solution would use this code, followed by a suitable comparison (>0, <0, >=0, <=0, etc.), followd by "and/or array elements" depending on the desired logic. No loop needed.
02-16-2016 10:50 PM - edited 02-16-2016 10:52 PM
Mathematically your answer is Difference (dx) if it is negative you have decreasing in your data and if it is positive you have increasing in your data and for zero you do not have change in data
it is the fact that all friends want to tell you
also I try to show you answer on dynamic type data by using Difference (dX) vi in labview
02-17-2016 12:20 AM
Advanced LabVIEW user typically don't use express VIs and dynamic data.
Your difference express VI receives more and more data without any upper limit. That's a lot of repetitive and unecessary work.
Afterwards you are throwing everything away and just keep one result when converting the dynamic data back.
Your shift register is uninitialized, thus the old day will not clear on the next run.
Your VI runs until stop is pressed, growing the array without bounds.
The original question asks for a subVI that takes an array as input and returns a boolean. Your VI does not do that.
02-17-2016 01:12 AM