LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

making standard deviation in each interaction

Hi 

 

I need help for calculating the standard deviation from a growing array. I need to do the following:data will be put into an array and i need to calculate the standard deviation of this array anytime i add an element on it. I also need to store all these values in a array and see them any 10 interactions.

Could anyone please help me? I hope i was able to explain my question.

thank you in advance. 

 

Cheers

cat

0 Kudos
Message 1 of 10
(4,171 Views)

That doesn't sound too bad. Does your array grow because you are collecting some data? If so, are you placing that data into an array that uses a shift register on a while loop?

 

If you are doing that it should be pretty straight forward to use the Std Deviation and Variance.vi that is in the following pallette: Mathematics -> Probability & Statistics on the array each time you gain a new element.

 

As for the history, does the user of the program specify which ten interactions they wish to see or is automatically the last ten?

 

What code have you done so far? Posting that will help me get a better idea how exactly to help! 

 

 

0 Kudos
Message 2 of 10
(4,166 Views)

Hi 

 

tanks for your help. In attachment i put a figure of the program. What it is doing now is to take the standard deviation in the end of the for loop, but i need it to take each interaction but it only needs to show me any 10 for example.

 

cheers

cat 

0 Kudos
Message 3 of 10
(4,156 Views)

So instead of using autoindexing at the end of the array build an array using shift registers. With each new element place it into the array on the shift register. Then, after the new element is added use the Standard Deviation and Variance vi. If you don't know about shift registers read the LabVIEW Help section under "shift registers". 

 

Also, by doing this you can use the Array Subset node to get any slice of the array you want. 

 

You're close!

 

Also, avoid using the sequence structure in the way you are using it. Force program execution with the error cluster line.

0 Kudos
Message 4 of 10
(4,147 Views)

thanks for you help i will try it 🙂

 

cheers cat

 

0 Kudos
Message 5 of 10
(4,142 Views)

Great! Let me know how it turns out.

0 Kudos
Message 6 of 10
(4,139 Views)

Building an array of undetermined size inside a loop may lead to performance degradation as the array builds.  A new data buffer is required for each successive iteration. 

 

You can calculate the standard deviation on the fly with Standard Deviation PtByPt.vi.  Place that VI inside the loop and wire in the temperature data.  Since the sample size is changing, wire the iteration count (+1) to the sample size terminal.  The standard deviation is recalculated each iteration using the new data point.

 

Similarly, using the DataQueue PtByPt.vi inside the loop with the sample size set to 10 as you suggested will output an array of the last 10 data items collected. Port the data outside the loop with an autoindexing tunnel as you showed in the sample.

 

Are you sure you want to convert the string returned from your instrument to a 32 bit integer then back to floating point number in your output arrays?  As it is now, your standard deviation will only reflect the integer part of the data.

 

JohnCS

0 Kudos
Message 7 of 10
(4,126 Views)

HI again

 

I've tried what you said but it doesn't work. The standard deviation.vi doesn't accept the input that comes from the array. I don't see why it doesn't.

i'm posting a fig of a test vi for this part of the program.

Thanks in advance for your help.

 

cheers

cat

0 Kudos
Message 8 of 10
(4,093 Views)

Hi,

 

May be this will help you.. I didn't use the StdDev function from palette. Directly applied the S.D formula which I got from here 🙂 Not sure whether this is a good way to do it. Just have a look.


Regards,


Nitzz

(Kudos are always Welcome, Mark as a solution if it the One;))

Download All
0 Kudos
Message 9 of 10
(4,088 Views)

The Point by Point VIs expect a scalar for each calculation.  

 

Adding 1 to the sample length turns out to be unnecessary since the Point by Point VIs takes care of the indexing for you if you explicitly initialize the VI on the first iteration. Setting the sample length to zero causes the VI to keep accumulating with each iteration. Setting the sample length to a specific value of n gets the statistic of the last n iterations.

 

Try this VI. 

 

JohnCS

Download All
0 Kudos
Message 10 of 10
(4,072 Views)