Reputation: 4246
Can someone help me understand where I'm going wrong below? I'm using mfilt.firinterp to interpolate a sinewave by a factor of 4 using a filter having a cutoff of 0.7*(fs/2). The sinewave has a frequency of 0.1Hz, and I'm sampling at 10Hz. The low-pass filter used for interpolation therefore has a cutoff of 3.5Hz, and should easily pass this signal. I must be doing something basic wrong.
If I set the cutoff to 0.25*fs/2, everything looks fine. But does this mean signals having frequency content slightly above 0.25*fs/2 (such as 0.4*fs/2), cannot be linearly interpreted (or, how would one accomplish this?).
Wait a minute, am I confusing the old fs and the new fs? If fs = fs_new = 40Hz, then I can understand what's going on. If I set the cutoff to 0.25*fs_new/2 where fs_new = 40Hz, then it makes sense this is the upper cutoff freq of 10 Hz (the original sampling rate). So, Wn in fircls1(95,Wn,0.01, 0.0001) must be <=0.25. Does that sound right?
Thanks in advance for any comments.
% create input
told = (0:1:299)/10; % time index for plotting xold
tnew = (0:1:1199)/40; % time index for plotting xnew
xold = sin(2*pi*0.1*told + 1); % fc=0.1Hz (Pc=10 sec); samplerate = fs = 10Hz
% create filter
num = fircls1(95, 0.7, 0.01, 0.0001); % set filter cutoff to 0.7*(fs/2)=3.5Hz
Hm = mfilt.firinterp(4,num);
% apply filter
xnew = 4*filter(Hm, xold);
% plot results
plot(told, xold, 'bo', tnew, xnew, 'r+');
title('Input (blue) and filtered input (red) versus time index');
Upvotes: 1
Views: 1404
Reputation: 4246
I figured out my mis-understanding... It was my confusion over the Wn parameter in using fircls1(n, Wn, ripple_passband, ripple_stopband). When using this function in conjuction with Matlab's function mfilt.firinterp(l,num), the Wn should be considered the cutoff frequency normalized to the NEW sampling frequency (and not the OLD sampling frequency, thus my confusion).
So, when interpolating by four (i.e. l=4) using mfilt.firinterp, Wn must be 0.25 or less to avoid aliasing (if Wn>0.25 then the images overlap).
In the above example I was trying to use Wn = 0.7, but in reality what I really should have used was Wn = 0.7*0.25, which is < 0.25.
Upvotes: 2
Reputation: 16193
Interesting question (upvoted and favourited) but I am unable to help as I do not have access to the filter design toolbox. You may have more luck pasting this question here:
http://www.mathworks.com/matlabcentral/newsreader/
Sorry and best of luck!
Upvotes: 0