LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting the number of iterations in a loop and eliminating the final data point from an iteration

Two Questions:

1.) The formula I had initally used in my formula node was A=(3.14*((x+y)/2)**2)/360. This formula is ok if I have 360 data points, but there may be cases where I have more or less data. I would like to automate the process of counting the number of values I have collected from the incoming waveform, but I don't know how. I have setp up a "divide by" commande where I need the value for the total number of data points to be. Does LV have a counter for this? I tried dividing by the total number of iterations of the while loop, but that didn't work.

2.) In the VI, I have it setup that the data collection and calculations will stop once the vol
tage goes above 5V. Once the Boolean condition is false, is there a way of stopping the very last data point from being included in the calculations?

Thanks for the help!
0 Kudos
Message 1 of 7
(4,043 Views)
,

This is easily solved by a simple technique. There are a couple ways to do it, but here is the one I use most:

reverse the 1D array. Use the "Delete from Array" function to remove the first element (n=0). Then, rereverse the array. You have just removed the last element.

If you are wanting the number of elements in an array, there is a function for this in the array tools palette.

If you want the count of an array, just wire the "i" out, and disable indexing. This will output the last value. From there, you can subract one.

Good luck.
0 Kudos
Message 2 of 7
(4,043 Views)
Hi
In LV6 you don't have to reverse the array first,
you can leave the index of "delete from array" unwired and it will remove the last element.
greetings from the Netherlands
0 Kudos
Message 3 of 7
(4,043 Views)
Greetings,

I'm sure the function is in labview, just can't find it in Help or forum. Basically I have amplitude values coming from a PNA. I'm using 401 pts., so basically 401 values. What I want to do is COUNT the number of values that are <3.05. With this number I'm then going to divide by the total  number of points (going to be a constant), which will give me the percent I need.
The data is 1D DBL. I'm just having a hard time finding a count feature, or extract values type feature. I feel silly almost posting this.

Thanks in advance for anyones help, I'm sure this isn't difficult, and I'm not sure why I'm having a hard time with this.

-Chazzzmd
0 Kudos
Message 4 of 7
(3,799 Views)

(That question would prabably deserve a new thread, because it has little to do with this 5 year old discussion ;))

Just do your comparison, convert the boolean array to 0,1 and sum it. If you expect to have arrays with more than 2^16 elements, you should convert to I32 before summing.

Here's a quick draft. Modify as needed:

 

 



Message Edited by altenbach on 12-13-2007 09:16 AM
0 Kudos
Message 5 of 7
(3,790 Views)
Greetings,

My deepest apologies for interupting a current thread. I fully agree with you. Just wanted to thank you for your response, it worked like a charm and my script is now complete.

-Chazzzmd
0 Kudos
Message 6 of 7
(3,756 Views)

I am glad it worked for you. 🙂

One little correction: The native output of "boolean to 0,1" is actually I16 (not U16), so you need to covert to I32 if you expect more than ~2^15 (not 2^16) TRUEs. 😉

0 Kudos
Message 7 of 7
(3,753 Views)