LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

moving average

Hello,

I work on CVI8.1. I'd like to make a moving average of a analog input signal. With DAQmxReadAnalogF64, I have read data in a buffer called gData and then I'd like to make the moving avarage of gData on 2seconds for example and have the result in an other buffer called mean for example.

I know "Mean" function (prototype: AnalysisLibErrType Mean (double Input_Array[], int Number_of_Elements, double *Mean);) but I don't want arithmetic average!

Can you help me?

Thanks.

Julien


0 Kudos
Message 1 of 4
(3,908 Views)

A simple moving average can be computed in a loop passing as input array your gData + offset and an appropriate number of samples to fit your 2 seconds:

for (i = 0, index = 0; i < totalsamples - 2SecWindow; i+= 2SecWindow) {
    Mean (gData + i, 2SecWindow, &avg[index]);
    index++;
}



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 4
(3,900 Views)
Thanks. but it doesn't work. 😞 I have some errors in my buffer size.
Can you see my project and explain me why it doesn't work.

Thanks a lot.

julien
Download All
0 Kudos
Message 3 of 4
(3,891 Views)
There is no problem now, I made a simple mean on my acquisition samples and I'll mean only time elapsed and real time frequency.

Thanks.

Julien
0 Kudos
Message 4 of 4
(3,846 Views)