summaryrefslogtreecommitdiff
path: root/716/CH9/EX9.7/Solved_Ex9_7.sce
blob: 40180ea4895eaddad956bb63011c8c6065f0fb17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//Determine the Response of LTI system if input x(n)={-1 1 2 1 -1} and impulse Response h(n)={-1 1 -1 1}
clc;
clear;
x=[-1 1 2 1 -1];
disp(x,'Input signal=>    x(n)=');
h=[-1 1 -1 1];
disp(h,'Impulse Response=>    h(n)=');
k=length(x)+length(h)-1;
for n=length(x)+1:1:k
    x(n)=0;//appending 0s
end
for n=length(h)+1:1:k
    h(n)=0;//appending 0s
end
n=0:1:k;

X=fft(x);
disp(X,'4 point FFT of x(n)=>');

H=fft(h);
disp(X,'4 point FFT of h(n)=>');

Y=X.*H;
y=ifft(Y);
disp(y,'Response to input,x(n)=>    y(n)=');