03-07-2019 10:44 AM
Hello guys,
I'm new to labview and I have a problem: I need to calculate the difference between two consecutive elements in an array (output array in my program), and do the average of that distance.
Since my program uses a peak detector to calculate a frequency, I need the average value of all the distances between consecutive peaks (and that would be my period average, 1/period average I get frequency average).
In my program I try doing a for cycle with N=#number of peaks found and it calculates the distance between the first element of the array and the 0-index. I thought it would work like this:
for(i=0;i<N;i++)
peak[i+1]-peak[i]=distance[i]
then do the average of the distance.
My program calculates that after N time.. when it reaches N, the Numeric 2 turns 0.
I am trying to learn labview as quickly as I can, so any help is VERY appreciated.
Solved! Go to Solution.
03-07-2019 10:55 AM - edited 03-07-2019 10:59 AM
Sorry, I don't understand your code, but to calculate the pairwise difference of the elements in a 1D array, just subtract a copy with the first element deleted to get the new 1D array. No loop needed.
I don;t have Drivers, so I cannot see most of your IO functions or help further. Can you make a version that generates synthetic data instead to show the behavior?
03-07-2019 11:27 AM
You are absolutely right! it's true you don't need a loop for that, sorry I'm an amateur to labview...
I need the array for now to show me the time values of peaks, but I will delete it when I finalize my program.
I will also try to look for the primitive 1/x!
Thank you a lot!!!