05-11-2017 06:14 AM
Hi,
i'm new to Labview. I'd like to get some helps to solve this kind of problem. I've got an array of integer in input and i must compare every element with previous one. If the element in i-th position is less than previous(i-1 th) then i must insert index of this element in another array in output, else if the element in i-th position is greather than previous(i-1 th) then i must insert zero in output array.
Example
Array in input=[1,36,2,3,43,6,8,1]
Array in output=[0,2,0,0,5,0,7]
Any helps would be kindly appreciated. Thank you so much.
Solved! Go to Solution.
05-11-2017
06:25 AM
- last edited on
06-22-2025
05:12 PM
by
Content Cleaner
Start with below links to learn about LabVIEW programming
3 Hour LabVIEW Introduction
6 Hour LabVIEW Introduction
LabVIEW Graphical Programming Course
05-11-2017 06:28 AM - edited 05-11-2017 06:34 AM
Hi ptavernise,
you need a FOR loop with a shift register.
By autoindexing through your input array you can compare the current element with the previous one you have stored in the shift register.
Connect the result of the comparison to a Select node and output either zero or the loop ietration count…
This is very basic LabVIEW stuff - you surely have seen the Getting Started section in the header of the LabVIEW board…
A different solution than the one described above:
05-11-2017 06:38 AM
This is the VI. I don't know why it doesn't work?
05-11-2017 07:02 AM - edited 05-11-2017 07:03 AM
Hi ptavernise,
you don't compare with previous value. Instead you compare with the previous result (zero or index)…
Additionally you shouldn't wire a constant to "N" when you want to employ autoindexing.
And you should create an array output (using autoindexing again) to create your "array 2"!
Why did you mark your own question with a erranous VI as solution?
05-11-2017 08:24 AM - edited 05-11-2017 08:36 AM
Hi,
i'm new to labview.I have a signal with its samples in an array and i like to find local maxima and minima, report it on the waveform and detect values of local maxima and minima. For example if we have i, i+1, i+2, i+3, i+4 we can define local maxima v[i+2] if v[i+2]>v[i],v[i+2]>v[i+1],v[i+2]>v[i+3],v[i+2]>v[i+4]. If we have i, i+1, i+2, i+3, i+4 we can define local minima v[i+2] if v[i+2]<v[i],v[i+2]<v[i+1],v[i+2]<v[i+3],v[i+2]<v[i+4].
How can i do?
Thank you so much
any help would be kindly appreciated
05-11-2017 08:32 AM
05-11-2017 08:38 AM
I know the definition but i don't know how to implement vi.This is the main problem.
05-11-2017 08:48 AM
05-11-2017 09:28 AM
This is the VI i have created. I cannot understand where is the error.Please help me, i really appreciate your help.
Thank you so much for helping me.