Documente Academic
Documente Profesional
Documente Cultură
FUNCTION GATEWAY: WINDOW(@WNAME,N) returns an N-point window of type specified by the function handle @WNAME in a column vector. WINDOW(@WNAME,N,OPT) designs the window with the optional input argument specified in OPT. To see what the optional input arguments are, see the help for the individual windows, for example, KAISER or CHEBWIN. 2) FREQZ :SYNTAX :Digital filter frequency response :[H,W] = FREQZ(B,A,N) returns the N-point complex frequency response vector H and the N-point frequency vector W in radians/sample of the filter: jw -jw -jmw jw B(e) b(1) + b(2)e + .... + b(m+1)e H(e) = ---- = -----------------------------------jw -jw -jnw A(e) a(1) + a(2)e + .... + a(n+1)e given numerator and denominator coefficients in vectors B and A. The frequency response is evaluated at N points equally spaced around the upper half of the unit circle. If N isn't specified, it defaults to 512. [H,W] = FREQZ(B,A,N,'whole') uses N points around the whole unit circle. 3) STEM :SYNTAX :Discrete sequence or "stem" plot :STEM(Y) plots the data sequence Y as stems from the x axis terminated with circles for the data value. STEM(X,Y) plots the data sequence Y at the values specified in X.
LENGTH(X) returns the length of vector X. It is equivalent to MAX(SIZE(X)) for non-empty arrays and 0 for empty ones. 28) BITREVORDER :SYNTAX :Permute input into bit-reversed orde :-
10
11
12
13
14
15
16
17
18
19
20
%Magnitude and phase response clc; close all; clear all; M=input('enter the no of samples'); n=0:1:M; xn=3.5*sin(2*pi*(0.15)*n)+sin(2*pi*(0.4)*n); [xnr,M]=freqz(xn,1,M+1) xrm=abs(xnr);%to clalculate magnitude xra=angle(xnr);%to claculate phase subplot(2,1,1) plot(n,xrm,'r'); subplot(2,1,2) plot(n,xra,'m');
21
22
23
24
25
26
27
N=16
28
N=128
29
30
31
N=64
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
case{3} A1=input('Enter the pass band ripple/gain'); A2=input('Enter stop band ripple/gain'); fp1=input('Enter the low passband frequency'); fs1=input('Enter the low stop band frequency'); fa=input('Enter sampling frequency'); fp2=input('Enter the high passband frequency'); fs2=input('Enter the high stop band frequency'); %CONVERT FREQUENCY IN HTZ TO RADIAN/SAMPLE wp1=2*fp1/fa; ws1=2*fs1/fa; wp2=2*fp2/fa; ws2=2*fs2/fa; wp=[wp1 wp2]; ws=[ws1 ws2]; wc1=(wp1+ws1)/2; wc2=(wp2+ws2)/2; wc=[wc1 wc2];
52
%CONVERT FREQUENCY IN HTZ TO RADIAN/SAMPLE wp1=2*fp1/fa; ws1=2*fs1/fa; wp2=2*fp2/fa; ws2=2*fs2/fa; wp=[wp1 wp2]; ws=[ws1 ws2]; wc1=(wp1+ws1)/2; wc2=(wp2+ws2)/2; wc=[wc1 wc2]; [N,wc]=buttord(wp,ws,A1,A2); [z,p,k]=butter(N,wc,'bandpass','z'); [n,d]=butter(N,wc,'bandpass','z'); otherwise disp('Inavlid option'); end w=0:0.01*pi:pi; H=freqz(n,d,w); hm=abs(H); ha=angle(H); subplot(2,1,1) stem(w,hm); title('Magnitude response of a filter'); subplot(2,1,2) stem(w,ha); title('Phase response of a filter ');
53
54
clc ; clear all ; close all ; format short ; N = input('Please enter the length of the DFT : ') ; for i = 1:N+1 if N == 2^i x = input('Please enter the input sequence : ') ; Z = fft(x,N) ; disp('FFT Sequence') ; disp(Z) ; subplot(2,1,1) ; stem(x) ; xlabel('N') ; ylabel('Amplitude') ; title('Input Sequence') ; subplot(2,1,2) ; stem(Z) ; xlabel('N') ; ylabel('Amplitude') ; title('FFT of the Input Sequence') ; break ; elseif N > 2^i else disp('Not a proper number') ; break ; end ; end ;
55
Original Signal 8 6 4 2 0
Amplitude---->
10 5 0 -5 -10 -5
Amplitude---->
10
15 n---->
20
25
30
35
40
56
clc ; clear all ; close all ; format short ; N = input('Please enter the length of the input sequence : ') ; for i = 1:N+1 if N == 2^i x = input('Please enter the input sequence : ') ; y = bitrevorder(x) ; Z = fft(y,N) ; disp('Input Sequence After Reversal') ; disp(y) ; disp('FFT Sequence') ; disp(Z) ; subplot(2,1,1) ; stem(x) ; xlabel('N') ; ylabel('Amplitude') ; title('Input Sequence') ; subplot(2,1,2) ; stem(Z) ; xlabel('N') ; ylabel('Amplitude') ; title('FFT of the Input Sequence') ; break ; elseif N > 2^i else disp('Not a proper number') ; break ; end ; end;
57
4 n-> -FT i nl FS a g
1 0 A p d ----> m litu e 5 0 5 -0 1 5
1 0
1 5 n-> --
2 0
2 5
3 0
3 5
4 0
58
59
60
clc; clear all; close all; F=input('enter the freq edges'); A=input('amplitude'); N=input('order of filter'); B=remez(N,F,A); [H,w]=freqz(B,1,N+1);
61
Output :-
62
63
Output :-
64
PRACTICAL-18
65
Output :-
66
67
PRACTICAL-19 %STABILITY
68
Output :-
69
70
PRACTICAL-20
71
Output :-
72
73