Make Every Step Count...
Blog under the control of EPSILON LABS...www.epsilonlabs.in
For immediate response/assistance mail to : epsilonlabs4@gmail.com
Program : clc; clear all; x = input('Enter the input sequence = '); N = length(x); for k = 1:N y(k) = 0; for n = 1:N y(k) = y(k)+x(n)*exp(-1i*2*pi*(k-1)*(n-1)/N); end end %code block to plot the input sequence t = 0:N-1; subplot(2,2,1); stem(t,x); ylabel('Amplitude ---->'); xlabel('n ---->'); title('Input Sequence'); grid on; magnitude = abs(y); % Find the magnitudes of individual FFT points disp('FFT Sequence = '); disp(magnitude); %code block to plot the FFT sequence t = 0:N-1; subplot(2,2,2); stem(t,magnitude); ylabel('Amplitude ---->'); xlabel('K ---->'); title('FFT Sequence'); grid on; R = length(y); for n = 1:R x1(n) = 0; for k = 1:R x1(n) = x1(n)+(1/R)*y(k)*exp(1i*2*pi*(k-1)*(n-1)/R); end end %code block to plot the IFFT sequence t = 0:R-1; subplot(2,2,3); stem(t,x1); disp('IFFT Sequence = '); disp(x1); ylabel('Amplitude ---->'); xlabel('n ---->'); title('IFFT sequence'); grid on; Output : Enter the input sequence = [1 4 2 5 2] FFT Sequence = 14.0000 2.8124 4.3692 4.3692 2.8124
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); fp = input('Enter the passband frequency = '); fs = input('Enter the stopband frequency = '); f = input('Enter the sampling frequency = '); r = input('Enter the ripple value(in dBs) = '); wp = 2*fp/f; ws = 2*fs/f; num = -20*log10(sqrt(rp*rs))-13; dem = 14.6*(fs-fp)/f; n = ceil(num/dem); if(rem(n,2)==0) n = n+1; end y = chebwin(n,r); % low-pass filter b = fir1(n-1,wp,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('Magnitude Response of LPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % high-pass filter b = fir1(n-1,wp,'high',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,2); plot(o/pi,m); title('Magnitude Response of HPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band pass filter wn = [wp ws]; b = fir1(n-1,wn,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,3); plot(o/pi,m); title('Magnitude Response of BPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band stop filter b = fir1(n-1,wn,'stop',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); title('Magnitude Response of BSF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; Output:
Enter the passband ripple = 0.03 Enter the stopband ripple = 0.02 Enter the passband frequency = 1800 Enter the stopband frequency = 2400 Enter the sampling frequency = 10000 Enter the ripple value(in dBs) = 40 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); fp = input('Enter the passband frequency = '); fs = input('Enter the stopband frequency = '); f = input('Enter the sampling frequency = '); beta = input('Enter the beta value = '); wp = 2*fp/f; ws = 2*fs/f; num = -20*log10(sqrt(rp*rs))-13; dem = 14.6*(fs-fp)/f; n = ceil(num/dem); n1 = n+1; if (rem(n,2)~=0) n1 = n; n = n-1; end y = kaiser(n1,beta); % low-pass filter b = fir1(n,wp,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('Magnitude Response of LPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % high-pass filter b = fir1(n,wp,'high',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,2); plot(o/pi,m); title('Magnitude Response of HPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band pass filter wn = [wp ws]; b = fir1(n,wn,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,3); plot(o/pi,m); title('Magnitude Response of BPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band stop filter b = fir1(n,wn,'stop',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); title('Magnitude Response of BSF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; Output:
Enter the passband ripple = 0.02 Enter the stopband ripple = 0.01 Enter the passband frequency = 1000 Enter the stopband frequency = 1500 Enter the sampling frequency = 10000 Enter the beta value = 5.8 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); fp = input('Enter the passband frequency = '); fs = input('Enter the stopband frequency = '); f = input('Enter the sampling frequency = '); wp = 2*fp/f; ws = 2*fs/f; num = -20*log10(sqrt(rp*rs))-13; dem = 14.6*(fs-fp)/f; n = ceil(num/dem); n1 = n+1; if (rem(n,2)~=0) n1 = n; n = n-1; end y = hanning(n1); % low-pass filter b = fir1(n,wp,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('Magnitude Response of LPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % high-pass filter b = fir1(n,wp,'high',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,2); plot(o/pi,m); title('Magnitude Response of HPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band pass filter wn = [wp ws]; b = fir1(n,wn,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,3); plot(o/pi,m); title('Magnitude Response of BPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band stop filter b = fir1(n,wn,'stop',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); title('Magnitude Response of BSF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; Output:
Enter the passband ripple = 0.03 Enter the stopband ripple = 0.01 Enter the passband frequency = 1400 Enter the stopband frequency = 2000 Enter the sampling frequency = 8000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); fp = input('Enter the passband frequency = '); fs = input('Enter the stopband frequency = '); f = input('Enter the sampling frequency = '); wp = 2*fp/f; ws = 2*fs/f; num = -20*log10(sqrt(rp*rs))-13; dem = 14.6*(fs-fp)/f; n = ceil(num/dem); n1 = n+1; if (rem(n,2)==50) n1 = n; n = n-1; end y = hamming(n1); % low-pass filter b = fir1(n,wp,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('Magnitude Response of LPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % high-pass filter b = fir1(n,wp,'high',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,2); plot(o/pi,m); title('Magnitude Response of HPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band pass filter wn = [wp ws]; b = fir1(n,wn,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,3); plot(o/pi,m); title('Magnitude Response of BPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band stop filter b = fir1(n,wn,'stop',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); title('Magnitude Response of BSF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; Output:
Enter the passband ripple = 0.02 Enter the stopband ripple = 0.01 Enter the passband frequency = 1200 Enter the stopband frequency = 1700 Enter the sampling frequency = 9000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); fp = input('Enter the passband frequency = '); fs = input('Enter the stopband frequency = '); f = input('Enter the sampling frequency = '); wp = 2*fp/f; ws = 2*fs/f; num = -20*log10(sqrt(rp*rs))-13; dem = 14.6*(fs-fp)/f; n = ceil(num/dem); n1 = n+1; if (rem(n,2)==50) n1 = n; n = n-1; end y = blackman(n1); % low-pass filter b = fir1(n,wp,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('Magnitude Response of LPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % high-pass filter b = fir1(n,wp,'high',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,2); plot(o/pi,m); title('Magnitude Response of HPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band pass filter wn = [wp ws]; b = fir1(n,wn,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,3); plot(o/pi,m); title('Magnitude Response of BPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band stop filter b = fir1(n,wn,'stop',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); title('Magnitude Response of BSF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; Output:
Enter the passband ripple = 0.03 Enter the stopband ripple = 0.01 Enter the passband frequency = 2000 Enter the stopband frequency = 2500 Enter the sampling frequency = 7000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); fp = input('Enter the passband frequency = '); fs = input('Enter the stopband frequency = '); f = input('Enter the sampling frequency = '); wp = 2*fp/f; ws = 2*fs/f; num = -20*log10(sqrt(rp*rs))-13; dem = 14.6*(fs-fp)/f; n = ceil(num/dem); n1 = n+1; if (rem(n,2)==50) n1 = n; n = n-1; end y = bartlett(n1); % low-pass filter b = fir1(n,wp,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('Magnitude Response of LPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % high-pass filter b = fir1(n,wp,'high',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,2); plot(o/pi,m); title('Magnitude Response of HPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band pass filter wn = [wp ws]; b = fir1(n,wn,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,3); plot(o/pi,m); title('Magnitude Response of BPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band stop filter b = fir1(n,wn,'stop',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); title('Magnitude Response of BSF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; Output:
Enter the passband ripple = 0.04 Enter the stopband ripple = 0.02 Enter the passband frequency = 1500 Enter the stopband frequency = 2000 Enter the sampling frequency = 8000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); fp = input('Enter the passband frequency = '); fs = input('Enter the stopband frequency = '); f = input('Enter the sampling frequency = '); wp = 2*fp/f; ws = 2*fs/f; num = -20*log10(sqrt(rp*rs))-13; dem = 14.6*(fs-fp)/f; n = ceil(num/dem); n1 = n+1; if (rem(n,2)==50) n1 = n; n = n-1; end y = boxcar(n1); % low-pass filter b = fir1(n,wp,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,1); plot(o/pi,m); title('Magnitude Response of LPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % high-pass filter b = fir1(n,wp,'high',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,2); plot(o/pi,m); title('Magnitude Response of HPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band pass filter wn = [wp ws]; b = fir1(n,wn,y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,3); plot(o/pi,m); title('Magnitude Response of BPF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; % band stop filter b = fir1(n,wn,'stop',y); [h,o] = freqz(b,1,256); m = 20*log10(abs(h)); subplot(2,2,4); plot(o/pi,m); title('Magnitude Response of BSF'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; Output:
Enter the passband ripple = 0.05 Enter the stopband ripple = 0.04 Enter the passband frequency = 1500 Enter the stopband frequency = 2000 Enter the sampling frequency = 9000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = cheb2ord(w1,w2,rp,rs); wn = [w1 w2]; [b,a] = cheby2(n,rs,wn,'stop'); w = 0:0.1/pi:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.3 Enter the stopband ripple = 46 Enter the passband frequency = 1400 Enter the stopband frequency = 2000 Enter the sampling frequency = 8000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = cheb2ord(w1,w2,rp,rs); wn = [w1 w2]; [b,a] = cheby2(n,rs,wn,'bandpass'); w = 0:0.01/pi:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.4 Enter the stopband ripple = 40 Enter the passband frequency = 1400 Enter the stopband frequency = 2000 Enter the sampling frequency = 9000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = cheb2ord(w1,w2,rp,rs); [b,a] = cheby2(n,rs,wn,'high'); w = 0:0.01/pi:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.25 Enter the stopband ripple = 40 Enter the passband frequency = 1400 Enter the stopband frequency = 1800 Enter the sampling frequency = 7000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = cheb2ord(w1,w2,rp,rs); [b,a] = cheby2(n,rs,wn); w = 0:0.01:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.35 Enter the stopband ripple = 35 Enter the passband frequency = 1500 Enter the stopband frequency = 2000 Enter the sampling frequency = 8000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = cheb1ord(w1,w2,rp,rs); wn = [w1 w2]; [b,a] = cheby1(n,rp,wn,'stop'); w = 0:0.1/pi:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.25 Enter the stopband ripple = 40 Enter the passband frequency = 2500 Enter the stopband frequency = 2750 Enter the sampling frequency = 7000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = cheb1ord(w1,w2,rp,rs); wn = [w1 w2]; [b,a] = cheby1(n,rp,wn,'bandpass'); w = 0:0.01:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.4 Enter the stopband ripple = 35 Enter the passband frequency = 2000 Enter the stopband frequency = 2500 Enter the sampling frequency = 10000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = cheb1ord(w1,w2,rp,rs); [b,a] = cheby1(n,rp,wn,'high'); w = 0:0.01/pi:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.3 Enter the stopband ripple = 60 Enter the passband frequency = 1500 Enter the stopband frequency = 2000 Enter the sampling frequency = 9000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = cheb1ord(w1,w2,rp,rs); [b,a] = cheby1(n,rp,wn); w = 0:0.01:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.2 Enter the stopband ripple = 45 Enter the passband frequency = 1300 Enter the stopband frequency = 1500 Enter the sampling frequency = 10000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = buttord(w1,w2,rp,rs); wn = [w1 w2]; [b,a] = butter(n,wn,'stop'); w = 0:0.01:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.4 Enter the stopband ripple = 46 Enter the passband frequency = 1100 Enter the stopband frequency = 2200 Enter the sampling frequency = 6000 Waveform:
Program: clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = buttord(w1,w2,rp,rs); wn = [w1 w2]; [b,a] = butter(n,wn,'bandpass'); w = 0:0.01:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output: Enter the passband ripple = 0.3 Enter the stopband ripple = 40 Enter the passband frequency = 1500 Enter the stopband frequency = 2000 Enter the sampling frequency = 9000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = buttord(w1,w2,rp,rs); [b,a] = butter(n,wn,'high'); w = 0:0.01:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.5 Enter the stopband ripple = 50 Enter the passband frequency = 1200 Enter the stopband frequency = 2400 Enter the sampling frequency = 10000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = buttord(w1,w2,rp,rs); [b,a] = butter(n,wn); w = 0:0.01:pi; [h,om] = freqz(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.5 Enter the stopband ripple = 50 Enter the passband frequency = 1200 Enter the stopband frequency = 2400 Enter the sampling frequency = 10000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = cheb2ord(w1,w2,rp,rs,'s'); wn = [w1 w2]; [b,a] = cheby2(n,rs,wn,'stop','s'); w = 0:0.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.25 Enter the stopband ripple = 30 Enter the passband frequency = 1300 Enter the stopband frequency = 2000 Enter the sampling frequency = 8000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = cheb2ord(w1,w2,rp,rs,'s'); wn = [w1 w2]; [b,a] = cheby2(n,rs,wn,'bandpass','s'); w = 0:0.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.37 Enter the stopband ripple = 37 Enter the passband frequency = 3000 Enter the stopband frequency = 4000 Enter the sampling frequency = 9000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = cheb2ord(w1,w2,rp,rs,'s'); [b,a] = cheby2(n,rs,wn,'high','s'); w = 0:0.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.34 Enter the stopband ripple = 34 Enter the passband frequency = 1400 Enter the stopband frequency = 1600 Enter the sampling frequency = 10000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = cheb2ord(w1,w2,rp,rs,'s'); [b,a] = cheby2(n,rs,wn,'s'); w = 0:0.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.4 Enter the stopband ripple = 50 Enter the passband frequency = 2000 Enter the stopband frequency = 2400 Enter the sampling frequency = 10000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = cheb1ord(w1,w2,rp,rs,'s'); wn = [w1 w2]; [b,a] = cheby1(n,rp,wn,'stop','s'); w = 0:0.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.15 Enter the stopband ripple = 30 Enter the passband frequency = 2000 Enter the stopband frequency = 2400 Enter the sampling frequency = 7000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = cheb1ord(w1,w2,rp,rs,'s'); wn = [w1 w2]; [b,a] = cheby1(n,rp,wn,'bandpass','s'); w = 0:0.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.3 Enter the stopband ripple = 40 Enter the passband frequency = 1400 Enter the stopband frequency = 2000 Enter the sampling frequency = 5000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = cheb1ord(w1,w2,rp,rs,'s'); [b,a] = cheby1(n,rp,wn,'high','s'); w = 0:0.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.29 Enter the stopband ripple = 29 Enter the passband frequency = 900 Enter the stopband frequency = 1300 Enter the sampling frequency = 7500 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = cheb1ord(w1,w2,rp,rs,'s'); [b,a] = cheby1(n,rp,wn,'s'); w = 0:0.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.23 Enter the stopband ripple = 47 Enter the passband frequency = 1300 Enter the stopband frequency = 1550 Enter the sampling frequency = 7800 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = buttord(w1,w2,rp,rs,'s'); wn = [w1 w2]; [b,a] = butter(n,wn,'stop','s'); w = 0:0.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); title('Magnitude Response'); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); grid on; subplot(2,1,2); plot(om/pi,an); title('Phase Response'); xlabel('Normalised Frequency ---->'); ylabel('Phase in radians ---->'); grid on; Output:
Enter the passband ripple = 0.28 Enter the stopband ripple = 28 Enter the passband frequency = 1000 Enter the stopband frequency = 1400 Enter the sampling frequency = 5000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n] = buttord(w1,w2,rp,rs); wn = [w1 w2]; [b,a] = butter(n,wn,'bandpass','s'); w = 0:.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); ylabel('Gain in dB ---->'); xlabel('Normalised Frequency ---->'); title('Magnitude Response'); grid on; subplot(2,1,2); plot(om/pi,an); xlabel('Normalised Frequency ---->'); ylabel('Phase in Radians ---->'); title('Phase Response'); grid on; Output:
Enter the passband ripple = 0.36 Enter the stopband ripple = 36 Enter the passband frequency = 1500 Enter the stopband frequency = 2000 Enter the sampling frequency = 6000 Waveform:
clc; clear all; rp = input('Enter the passband ripple = '); rs = input('Enter the stopband ripple = '); wp = input('Enter the passband frequency = '); ws = input('Enter the stopband frequency = '); fs = input('Enter the sampling frequency = '); w1 = 2*wp/fs; w2 = 2*ws/fs; [n,wn] = buttord(w1,w2,rp,rs,'s'); [b,a] = butter(n,wn,'high','s'); w = 0:0.01:pi; [h,om] = freqs(b,a,w); m = 20*log10(abs(h)); an = angle(h); subplot(2,1,1); plot(om/pi,m); ylabel('Gain in dB ---->'); xlabel('Normalised frequency ---->'); title('Amplitude Response'); grid on; subplot(2,1,2); plot(om/pi,an); xlabel('Normalised frequency ---->'); ylabel('Phase in radians ---->'); title('Phase Response'); grid on; Output:
Enter the passband ripple = 0.2 Enter the stopband ripple = 40 Enter the passband frequency = 2000 Enter the stopband frequency = 3500 Enter the sampling frequency = 8000 Waveform: