Hi,Trying to use the M-file "filter" to filter out a high-freq signal from a composite signal. num,den gives the co-efficients of a Low-Pass filter with cut-off freq near 0.25*pi The filter works fine when the step_size variable is greater than 0.8 The smaller i make the step_size, the worse the filter operation. The code (as taken from mitra's book on dsp with plots added) is below - ---------------- % program 8_2 from sanjit k. mitra's text on DSP % illustration of filtering by a lowpass iir filter % generate the input sequence step_size=1; % making this step_size lower than 0.6 say, breaks the filter k=1:step_size:50; w1=0.8*pi; w2=0.1*pi; A=1.5; B=2.0; x1=A*cos(w1*(k-1)); x2=B*cos(w2*(k-1)); x=x1+x2; % the composite signal % generate the output sequence by filtering the input si = [0 0 0]; num=0.0662272*[1 3 3 1]; den=[1 -0.93561864 0.56712991716567 -0.10159281020491]; y=filter(num,den,x,si); % plot the input and the output sequences subplot(2,1,1); plot(k-1,x); axis([0 49 -4 4]); xlabel('Time index n'); ylabel('Amplitude'); title('Input sequence'); subplot(2,1,2); plot(k-1,y(1:length(k))); axis([0 49 -4 4]); xlabel('Time index n'); ylabel('Amplitude'); title('Output sequence'); ---------------------------- I think by making the step_size finer, the length of the input signal (x in this case) becomes large. Is this the reason for the breakdown? Should i break down the input sequence into chunks of segments? If yes, what is the basis of choosing the "chunk length"? Please enlighten me on what the problem is. Any leads on solving this problem is appreciated greatly. Thanks. -vj |

# question on the usage of the m-file "filter"

Started by ●September 21, 2004