04-15-2009 03:35 AM
Hello everybody!
I have got a small problem. I need the mean value of a signal. For example the mean value of a signal in 10 seconds or in 5 seconds. So I set the sample length f.e. 10 put my stuff in an if loop, set a waiting time of 1000ms. But at the end I get all the 10 values and I only need the last one (in this case the tenth). Is it the wrong way to solve that problem? Is there another oppurtunity?
I woluld say thank you for every help moving me forward,
Thomas
Solved! Go to Solution.
04-15-2009 03:38 AM
Hi Thomas,
Do you want the last value or the mean value?
To get the last value, simply right-click the terminal of the for loop and disable auto-indexing.
If you want the mean value you could use a shift register to sum up the values in the loop and divide by the number of samples after the loop. Or you can use the array of values that you get now (with auto-indexing enabled) and use the mean function.
Hope this helps,
Daniel
04-15-2009 04:25 AM
Thank you for your answer, but I think I asked my question wrongly.
So I need the mean value of a signal. For example the mean value of every five seconds of this signal. If I use the mean function it will give so many values out at the output, how many I gave in at the input. But I only need the mean value of the 5 seconds and it gives me a mean value in every seconds (if I have a waiting time of 1000ms in my while loop). So I meant from these mean values the last one.
Thank you for helping me,
Thomas
04-15-2009 04:40 AM
Sorry, I still don't understand what you want. You sample your data at 1s. Do you want the mean value over 5 samples (=5 seconds)? Or just the last of the 5 samples?
Can you post what you have so far?
04-15-2009 06:01 AM
So this is my vi. It looks really easy. The input signal is an elapsed time signal to make it easily followable. If you run it, you will have mean values. At the input of the mean function 0, 1, 2, 3, 4, 5 aso. will come
at the same time at the output:
0,5 - (mean value of: 0,1);
1 - (mean v of 0,1,2);
2 - (mean v of 1,2,3);
3 - (mean v of 2,3,4);
4 - (mean v of 3,4,5) aso. because the sample length is 3.
But I need only the mean value of (0,1,2) and (3,4,5). Can I get only these values somehow?
04-15-2009 06:27 AM
Hi raditomi,
the attached picture shows one solution.
There is one other case "default", it's empty.
Mike
04-15-2009 06:28 AM
mean PtbyPt.vi
see help and don't forget to init ONCE you set the sample lenght
04-16-2009 03:47 AM
Hello Mike,
your picture was a great help for me. I solved the problem with the help of it.
I think I could not discribe what exactly my problem was.
Thanks a lot for helping me,
Thomas