Program Code
clc;close all;
clear all;
wc=input('Input the cut-off frequency in radians(less than pi)');
M=input('Input the length of ideal filter');
if wc>pi
error('cut-off frequency should be less than pi')
return
end
alpha=(M-1)/2;
n=0:1:(M-1);
m=n-alpha+eps;
hd=sin(wc*m)./(pi*m);
if nargout==0
stem(n,hd);
title('Impulse response of ideal low pass filter');
xlabel('n');
ylabel('hd(n)');
end
Example of Output
Input the cut-off frequency in radians(less than pi) 3Input the length of ideal filter 50
ans =
Columns 1 through 7
-0.0123 0.0133 -0.0141 0.0147 -0.0151 0.0152 -0.0149
Columns 8 through 14
0.0143 -0.0134 0.0120 -0.0102 0.0079 -0.0050 0.0016
Columns 15 through 21
0.0025 -0.0075 0.0134 -0.0207 0.0297 -0.0412 0.0569
Columns 22 through 28
-0.0800 0.1194 -0.2074 0.6350 0.6350 -0.2074 0.1194
Columns 29 through 35
-0.0800 0.0569 -0.0412 0.0297 -0.0207 0.0134 -0.0075
Columns 36 through 42
0.0025 0.0016 -0.0050 0.0079 -0.0102 0.0120 -0.0134
Columns 43 through 49
0.0143 -0.0149 0.0152 -0.0151 0.0147 -0.0141 0.0133
Column 50
-0.0123
___________________________
No comments:
Post a Comment
Please write your opinion about this MATLAB program here, only in English.