LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to program a C like pragraming in formula node?

Now my problem is I also want the index of the 0.707maxvalue of the array. How can I do it?
0 Kudos
Message 11 of 17
(1,183 Views)
Now I also want to get the index of the 0.707maxvalue of the array. How can I do it?
0 Kudos
Message 12 of 17
(1,183 Views)
Look at the example I posted on 8/15/03. Just multiply the max by 0.707, whether you're using a formula node or LabView functions. My example shows both.
0 Kudos
Message 13 of 17
(1,183 Views)
Les:
Good point! If a[0] is the max, x never gets updated in the loop, but it wasn't initialized outside of the loop.
Just another reason to use the LabView Array Max & Min function instead of a formula node. Reinventing the wheel is bad enough if you do it right.
0 Kudos
Message 14 of 17
(1,183 Views)
I saw the example you posted. It only gave the maxvalue & its index, and 0.707maxvalue. But now I need is the index of the 0.707maxvalue. I there any help?
0 Kudos
Message 15 of 17
(1,005 Views)
So you found the max value, but now want to find the index of the value that's 0.707 of the max (if that value exists in the array)?
There is a Search 1D Array function on the Array function palette, but you probably can't use it because it only finds an exact match. If your numbers are real measurements or calculations, you shouldn't expect to have an exact match.
After you find the max, go into a For loop, auto-indexed by the array. Decide what tolerance you want to add to 0.707 * max. Use functions on the Comparison function palette to determine if the current array element is within your tolerance of 0.707 * max. If it is, the For loop iteration (i) terminal has the value of the index. Wire the in
dex through a Case structure or a Select function (from the Comparison function palette) to a shift register on the For loop.
Or, if you want to stop at the first occurance, use a While loop, auto-index the array, and stop the While loop if the array element is within your tolerance of 0.707 * max or if you're at the end of the array (While loop iteration (i) terminal = array size - 1).
0 Kudos
Message 16 of 17
(1,005 Views)
See my updated example attached here.
0 Kudos
Message 17 of 17
(1,005 Views)