LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the sum of every measurement and further to get the average value of the whole measurement?

Hello all,
 
I need do one measurement several times, and add the values of every time, then divide the sum by the number of the measurement to get the average value.
 
Now my problem is I only can get the value of every time in a file, how to get the sum of the every measurement, and further to divide the sum to get the average value finally?
 
I only need the average value of "WRITE TO MEASUREMENT FILE" and "WRITE TO MEASUREMENT FILE4"
 
Thnak you for any help!
 
Jing


帖子被菁菁在05-19-2008 10:42 AM时编辑过了
0 Kudos
Message 1 of 15
(4,139 Views)
How is your VI supposed to be run? I don't see a loop. Is it a subVI? Are you using the "Run Continuously" button in the toolbar? If so, don't do that. That's supposed to be used for special debugging situations. If you're supposed to be running this VI continously, use a while loop around your code so you get more than one reading.
0 Kudos
Message 2 of 15
(4,129 Views)
Hi jing,
how are you?
Did you call this vi in a loop? See the attached picture please, are this your measurement values from which you need the average?
 
Mike
0 Kudos
Message 3 of 15
(4,103 Views)

Thank you smercurio_fc and Mike!

To smercurio_fc:  I tried to use a for loop around my whole code, but I can not get more than one reading, so maybe I need to try the while loop which you recommended.

To Mike: Sorry for no reply your messages as I have a lot of stuff to handle these days. and now I'm gonna be OK! Thank you again!

I need to run the whole VI several times to get the different values and then to get the average value. See the attached picture please, These two are the measurement values from which I need the average.

and after I get the different values in several files, How can I get the sum of every measurement and further to get the average value of the whole measurement?

Thank you for any help!

Jing



帖子被菁菁在05-20-2008 03:34 AM时编辑过了

帖子被菁菁在05-20-2008 03:39 AM时编辑过了
0 Kudos
Message 4 of 15
(4,070 Views)
Hi jing,
i don´t see your attached picture, only a vi with two write functions in it. See the attached picture, it shows an example how you get your average.
 
 
Mike


Message Edited by MikeS81 on 05-20-2008 11:14 AM
Message 5 of 15
(4,049 Views)

Mike

You didn't get what I mean,  sorry for misunderstanding! the two write fuction files are the files which I want to get the average value, you can see my original VI, there are 4 write function files, please notice the number of files, I only need the average value of "WRITE TO MEASUREMENT FILE" and "WRITE TO MEASUREMENT FILE4"

Every time I run my VI, it can generate a data file in the path of which "WRITE TO MEASUREMENT FILE4" defined, also in "WRITE TO MEASUREMENT FILE". and if I run my VI again, it can generate a new data file in the same path of which these two write function files difined. So if I run my VI in several times, then I can get several data files in the same path of these two write function files.

Now I need to avoid the noise of the data values, so I need to get the average value. for example in the path of "WRITE TO MEASUREMENT FILE4" defined, now in this path, I have several files corresponding to the times I run my VI. now I want to get the sum of the whole values in this path, and then divide the number of files which I already got, then I can get the average value.

That is what I mean, sorry for misunderstanding, Do u have some idea? how to get the average value in this way?

Jing

0 Kudos
Message 6 of 15
(4,043 Views)

Hi Jing,

here is an example, like i understand what you need. It read all files from the specified folder and calculates an average of the arrays.
Hope it helps. Smiley Happy

Mike

0 Kudos
Message 7 of 15
(4,038 Views)

WOW!  Mike

I tried your method just now, This is really a good method.

Danke Schön !!!

Jing

0 Kudos
Message 9 of 15
(4,023 Views)

Hi Mike

First I need to state I made a mistake yesterday, the average value I want to get is not in the ""WRITE TO MEASUREMENT FILE" but in the "WRITE TO MEASUREMENT FILE2" of my original VI.

I need to get the diagram of the average value to further analyze, so I need the X and Y information of the average value. the VI you gave me yesterday can get the average value for both "WRITE TO MEASUREMENT FILE" and "WRITE TO MEASUREMENT FILE2". The first data file from the "READ FROM MEASUREMENT FILE" have 2 channels corresponding to X and Y information,  but the second data file from the "READ FROM MEASUREMENT FILE" have only 1 channel, only corresponding to Y information.  

The strange thing is thses two data files look same, I put them into attached file, you can check. The difference between thses two is that the second data file is the FFT transformation of the first one. I also put the "configure write to measurement file" and show the differences for these two,  Do you have some idea why I lost the X information for the FFT transformation and how to handle it?

Thank you for any help!

Jing

Download All
0 Kudos
Message 10 of 15
(3,988 Views)