Why do I observe a shift in mean when using the DECIMATE function in MATLAB 6.5 (R13)?

Technical Source
2 min readJan 11, 2021

--

When I use the DECIMATE function using the following command:

load p3.txtplot(p3(:,1),p3(:,2),'k.');grid on; hold on;y=decimate(p3(:,2),31);y2=decimate(p3(:,2),31,n);t=linspace(p3(1,1),p3(end,1),255)';p3dec31=[t y];plot(p3dec31(:,1),p3dec31(:,2),'g*',t,y2,'go');[mean(p3(:,2)) mean(y)]

I observe a shift in the mean when viewing the plot. I can also verify the same from the command line:

[mean(p3(:,2)) mean(y)] as these two values are different.

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

The shift in the mean is caused by the order of the filter used in DECIMATE. By default, an 8th order Chebyshev Type I Low Pass Filter is used as an anti-aliasing filter before removing samples. However, there is a cost function that evaluates the magnitude response of the filter at the cut-off frequency to determine the filter order. Depending on the machine used (Intel Pentium, AMD Athlon, etc) and the operating system (Windows XP, Linux, etc), different numerical libraries produce different results in the cost function and as a result, different filter orders are selected for the same DECIMATE command.

Even order filters generate a 0.05 dB attenuation at f = 0, which then produces the shift in the mean. Odd order filters do not exhibit this behavior at f = 0 and hence do not produce the shift in the mean.

The workaround is to use DECIMATE with the FIR filter option. The FIR filter does not have a 0.05 dB attenuation at f = 0 and hence the shift in mean does not appear in the downsampled signal.

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet