Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Fitering without using Matlag filter fuction

Status
Not open for further replies.

Sovaa

Newbie level 2
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(y));
pojacanje=1/max(y)
end;

y = filter(NUM,DEN,x);


figure;
subplot(2,1,1);
%plot(y, '.');
plot(y);
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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top