Fitering without using Matlag filter fuction

Status
Not open for further replies.

Sovaa

Newbie level 2
Joined
Jan 6, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
I have a task i need to do but i'm not sure how to filter the signal without using Matlab filter function. Here is the code of the filter:

L =8;

x1 = [ones(1,L/2) -ones(1,L/2)];

%Input Signal

x = [x1 x1 x1 x1 x1 x1];

figure;
subplot(2,1,1);
stem(x, 'g');
title('Input signal in time domain');

X = fft(x,L);
SX = abs(X);
%length(SX)

%pols of linear system
P(1) = exp(j*2*pi*(3/L));
P(2) = conj(exp(j*2*pi*(3/L)));

subplot(2,1,2);
stem(0:L-1,SX , 'g');
title('Amplitude specter of input signal');

%zeros of linear system
Z = [];
for i = 1:L
if SX(i) > 0
Z = [Z exp(j*2*pi*(i-1)/L)];
end;
end;

if L == 8
a = [1 -2*cos(2*pi*(1/8 )) 1];
R = polyval(a,exp(2*pi*j*(3/8 )));
K = 1/abs(R)
[NUM,DEN] = zp2tf(Z.',P.',K)
else
[NUM,DEN] = zp2tf(Z.',P.',1);
y = filter(NUM,DEN,x);
[NUM,DEN] = zp2tf(Z.',P.',1/max);
pojacanje=1/max
end;

y = filter(NUM,DEN,x);


figure;
subplot(2,1,1);
%plot(y, '.');
plot;
title('Filtrated input signal(Time domain)');

I have to get the same result but without using function " filter(NUM,DEN,x)

If anyone can help i would appreciate it very much
 

Write your own filter function using the difference equations given NUM & DEN.
 

Well if I understood correctly, You can do a moving average filter without using any filter commands.
 

Well if i do a moving average filter it seams to me that i do not get sinusoidal signal of my input signal. Am i wrong?
 

It depends. If Your signal have additional higher frequency signals then those signals will be filtered. You will have a sine output.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…