NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

1butterworth bandstop Rs=input('Accepted ripples in passband in dB : ');
Rp=input('Accepted ripples in stopband in dB : ');
Fs=input('Stopband frequncy in Hz : ');
Fp=input('Passband frequncy in Hz : ');
F=input('Enter sampling frequency : ');
Ws=2*Fs/F; %Normalized edge frequencies
Wp=2*Fp/F;
[n,Wn]=buttord(Wp,Ws,Rp,Rs);
[b,a] = butter(n,Wn,'stop'); %[b,a] = butter(n,Wn,'ftype')
w=0:0.001:pi;
[h,w] = freqz(b,a,w);
Magh=abs(h);
MagdB=20*log10(Magh);
Phang=angle(h);
plot(w/pi,MagdB);
title('Magnitude Plot of Butterworth Filter (StopBand) in dB');
xlabel('Normailzed Frequency (Hz)');
ylabel('Magnitude (dB)');

2 bw highpassRs=input('Accepted ripples in passband in dB : ');
Rp=input('Accepted ripples in stopband in dB : ');
Fs=input('Stopband frequncy in Hz : ');
Fp=input('Passband frequncy in Hz : ');
F=input('Enter sampling frequency : ');
Ws=2*Fs/F; %Normalized edge frequencies
Wp=2*Fp/F;
[n,Wn]=buttord(Wp,Ws,Rp,Rs);
[b,a] = butter(n,Wn,'high'); %[b,a] = butter(n,Wn,'ftype')
w=0:0.001:pi;
[h,w] = freqz(b,a,w);
Magh=abs(h);
MagdB=20*log10(Magh);
Phang=angle(h);
plot(w/pi,MagdB);
title('Magnitude Plot of Butterworth Filter (HPF) in dB');
xlabel('Normalized Frequency (Hz)');
ylabel('Magnitude (dB)');

3bw low pass
Rs=input('Accepted ripples in passband in dB : ');
Rp=input('Accepted ripples in stopband in dB : ');
Fs=input('Stopband frequncy in Hz : ');
Fp=input('Passband frequncy in Hz : ');
F=input('Enter sampling frequency : ');
Ws=2*Fs/F; %Normalized edge frequencies
Wp=2*Fp/F;
[n,Wn]=buttord(Wp,Ws,Rp,Rs);
[b,a] = butter(n,Wn,'low'); %[b,a] = butter(n,Wn,'ftype')
w=0:0.001:pi;
[h,w] = freqz(b,a,w);
Magh=abs(h);
MagdB=20*log10(Magh);
Phang=angle(h);
%subplot(2,1,1);
plot(w/pi,MagdB);
title('Magnitude Plot of Butterworth Filter (LPF) in dB');
xlabel('Normalized Frequency (Hz)');
ylabel('Magnitude (dB)');
%subplot(2,1,2);
%plot(w/pi,Phang);
%title('Phase Angle Plot of Butterworth Filter');
%xlabel('Frequency (Hz)');
%ylabel('Magnitude (dB)');
4 cherrrybhew low pass
Rs=input('Accepted ripples in passband in dB : ');
Rp=input('Accepted ripples in stopband in dB : ');
Fs=input('Stopband frequncy in Hz : ');
Fp=input('Passband frequncy in Hz : ');
F=input('Enter sampling frequency : ');
Ws=2*Fs/F; %Normalized edge frequencies
Wp=2*Fp/F;
[n,Wn]=cheb1ord(Wp,Ws,Rp,Rs);
[b,a] = cheby1(n,Rp,Wn); %[b,a] = butter(n,Wn,'ftype')
w=0:0.001:pi;
[h,w] = freqz(b,a,w);
Magh=abs(h);
MagdB=20*log10(Magh);
Phang=angle(h);
plot(w/pi,MagdB);
title('Magnitude Plot of Chebychev Filter Type I (LPF) in dB');
xlabel('Normalized Frequency (Hz)');
ylabel('Magnitude (dB)');
5 cheerybhewRs=input('Accepted ripples in passband in dB : ');
Rp=input('Accepted ripples in stopband in dB : ');
Fs=input('Stopband frequncy in Hz : ');
Fp=input('Passband frequncy in Hz : ');
F=input('Enter sampling frequency : ');
Ws=2*Fs/F; %Normalized edge frequencies
Wp=2*Fp/F;
[n,Wn]=cheb1ord(Wp,Ws,Rp,Rs);
[b,a] = cheby1(n,Rp,Wn,'high'); %[b,a] = butter(n,Wn,'ftype')
w=0:0.001:pi;
[h,w] = freqz(b,a,w);
Magh=abs(h);
MagdB=20*log10(Magh);
Phang=angle(h);
plot(w/pi,MagdB);
title('Magnitude Plot of Chebychev Filter Type I (HPF) in dB');
xlabel('Normalized Frequency (Hz)');
ylabel('Magnitude (dB)');
high pass
6liner convo

clc;
n= input(“Enter n:”);
x1= input(“ Enter First Sequence:”);
m= input(“Enter m:”);
x2=input(“Enter Second Sequence:”);
k= min(n)+min(m):max(n)+max(m);
x3=conv(x1,x2);
stem(k,x3);
title(“Linear Conv”);
xlabel(“Time”);
ylabel(“Amplitude”);
7bpf

Bpf
N=7;
w=0:0.01:pi;
n=0:1:N-1;
eps=0.001;
alpha=(N-1)/2;
wc1=pi/3;
wc2=(2*pi)/3;
A=sin(wc1*(n-alpha+eps));
B=sin(wc2*(n-alpha+eps));
C=sin(pi*(n-alpha+eps));
D=pi*(n-alpha+eps);
hl=A./D;
hh=(C-B)./D;
hbs=(A-B+C)./D;
hbp=(B-A)./D;
wb=blackman(N);
whm=hamming(N);
whn=hanning(N);
wr=boxcar(N);%boxcar fn is which is zero over entire real line except an interval at which it equals A
hbpb=hbp.*transpose(wb);
hbphm=hbp.*transpose(whm);
hbphn=hbp.*transpose(whn);
hbphr=hbp.*transpose(wr);
hbpbf=freqz(hbpb,1,w);
hbphmf=freqz(hbphm,1,w);
hbphnf=freqz(hbphn,1,w);
hbphrf=freqz(hbphr,1,w);
subplot(2,4,1)
plot(w,abs(hbpbf));
title('bpf using blackman window');
xlabel('w');
ylabel('magnitude of bpf');
grid on
subplot(2,4,2)
plot(w,abs(hbphmf),'linewidth',2);
title('bpf using hamming window');
xlabel('w');
ylabel('magnitude of bpf');
subplot(2,4,3)
plot(w,abs(hbphnf),'linewidth',4);
title('bpf using hanning window');
xlabel('w');
ylabel('magnitude of bpf');
subplot(2,4,4)
plot(w,abs(hbphrf),'linewidth',6);
title('bpf using boxcar');
xlabel('w');
ylabel('magnitude of bpf');
subplot(2,4,5)
plot(w,angle(hbpbf));
xlabel('w');
ylabel('phase of bpf');
grid on
subplot(2,4,6)
plot(w,angle(hbphmf),'linewidth',2);
xlabel('w');
ylabel('phase of bpf');
grid on
subplot(2,4,7)
plot(w,angle(hbphnf),'linewidth',4);
xlabel('w');
ylabel('phase of bpf');
grid on
subplot(2,4,8)
plot(w,angle(hbphrf),'linewidth',6);
xlabel('w');
ylabel('phase of bpf');
grid on
8circu convo
a=[1 2 1 1];
b=[1 1 1 2];
c=ifft((fft(a,4).*fft(b,4)),4);
d=cconv(a,b,4);
subplot(2,2,1)
stem(a);
ylabel('Amplitude');
title('Signal 1');
grid;
subplot(2,2,2)
stem(b);
ylabel('Amplitude');
title('Signal 2');
grid;
subplot(2,2,3)
stem(d);
ylabel('Amplitude');
title('Convolution using CCONV');
grid;
subplot(2,2,4)
stem(c);
ylabel('Amplitude');
title('Convolution using FFT');
grid;
91) Linearity:
clf;
n = 0:40;
a = 2;
b = -3;
x1 = cos(2*pi*0.1*n);
x2 = cos(2*pi*0.4*n);
x = a*x1+b*x2;
num = [1 -2];
den = [1 0.5];
ic = [0]; %set zero initial conditions
y1 = filter(num,den,x1,ic); %compute the output y1[n]
y2 = filter(num,den,x2,ic); %compute the output y2[n]
y = filter(num,den,x,ic); %compute the output y[n]
yt = a*y1+b*y2;
d = y-yt; %compute the difference output d[n]
%plot the output and the difference signal
subplot(3,1,1)
stem(n,y);
ylabel('Amplitude');
title('Output due to weighted input:a.x_{1}[n]+b.x_{2}[n]');
subplot(3,1,2);
stem(n,yt);
ylabel('Amplitude');
title('Weighted Output: a.y_{1}[n]+b.y_{2}[n]');
subplot(3,1,3)
stem(n,d);
xlabel('Time index n');
ylabel('Amplitude');
title('Difference Signal');


2) Time Variant Invariant:
% Generate the input sequences
clf;
n=0:40;
D=10;
a=3;
b=-2;
x=a*cos(2*pi*0.1*n) + b*cos(2*pi*0.4*n);
xd=[zeros(1,D) x];
num=[1 -2];
den = [1 0.5];
ic = [0]; % Set initial conditions
% Compute the output y[n]
y = filter(num,den,x,ic);
% Compute the output yd[n]
yd = filter(num,den,xd,ic);
% Compute the difference output d[n]
d = y - yd(1+D : 41+D);
% Plot the outputs
subplot(3,1,1);
stem(n,y);
ylabel('Amplitude');
title('Output y[n]');
grid;
subplot(3,1,2)
stem(n,yd(1:41));
ylabel('Amplitude');
title(['Output due to Delayed Input x[n-D',num2str(D),']']);
grid;
subplot(3,1,3)
stem(n,d);
xlabel('Time Index n');
ylabel('Amplitude');
title('Difference Signal');
grid;

3) Time Scaling:
n = 0:1:10;
xn1 = (1/2).^n;
subplot(2,1,1)
stem(n,xn1);
xlabel('time');
ylabel('x1[n]');
title('discrete signal ');
yn1=(1/2).^(2*n);
subplot(2,1,2)
stem(n,yn1);
xlabel('time');
ylabel('y1[n]');
title('scaled signal');
10 samp in multirate
clf;
n = 0:50;
x = sin(2*pi*0.12*n);
y = zeros(1, 3*length(x));
y([1: 3: length(y)]) = x;
subplot(2,2,1)
stem(n,x);
title('Input Sequence');
xlabel('Time index n');
ylabel('Amplitude');
subplot(2,2,2)
stem(n,y(1:length(x)));
title('Output Sequence');
xlabel('Time index n');
ylabel('Amplitude');
n = 0: 49;
m = 0: 50*3 - 1;
x = sin(2*pi*0.042*m);
y = x([1: 3: length(x)]);
subplot(2,2,3)
stem(n, x(1:50));
axis([0 50 -1.2 1.2]);
title('Input Sequence');
xlabel('Time index n');
ylabel('Amplitude');
subplot(2,2,4)
stem(n, y);
axis([0 50 -1.2 1.2]);
title('Output Sequence');
xlabel('Time index n');
ylabel('Amplitude');
11 samp
Exp1) To Study Sampling Theorem and Effect of UnderSampling

t = 0:1/2000:.02;
x = cos(2*pi*60*t); % approx. to continuous-time
t240 = 0:1/240:.02;
n240 = 0:length(t240)-1;
x240 = cos(2*pi*60/240*n240); % fs = 240 Hz
axis([0 4.8 -1 1]) % axis scale since .02*240 = 4.8
t1000 = 0:1/1000:.02;
n1000 = 0:length(t1000)-1;
x1000 = cos(2*pi*60/1000*n1000); % fs = 1000 Hz
subplot(3,1,1)
plot(t,x);
xlabel('time');
ylabel('x[t]');
title('cosine signal');
subplot(3,1,2)
stem(n240,x240);
xlabel('time');
ylabel('x1[n]');
title('low sampling rate');
subplot(3,1,3)
stem(n1000,x1000);
xlabel('time');
ylabel('x2[n]');
title('high sampling rate');
12LPF using different window

N=7;
w=0:0.01:pi;
n=0:1:N-1;
eps=0.001;
alpha=(N-1)/2;
wc1=pi/3;
wc2=(2*pi)/3;
A=sin(wc1*(n-alpha+eps));
B=sin(wc2*(n-alpha+eps));
C=sin(pi*(n-alpha+eps));
D=pi*(n-alpha+eps);
hl=A./D;
hh=(C-B)./D;
hbs=(A-B+C)./D;
hbp=(B-A)./D;
wb=blackman(N);
whm=hamming(N);
whn=hanning(N);
wr=boxcar(N);%boxcar fn is which is zero over entire real line except an interval at which it equals A
hlb=hl.*transpose(wb);
hlhm=hl.*transpose(whm);
hlhn=hl.*transpose(whn);
hlhr=hl.*transpose(wr);
hlbf=freqz(hlb,1,w);
hlhmf=freqz(hlhm,1,w);
hlhnf=freqz(hlhn,1,w);
hlhrf=freqz(hlhr,1,w);
subplot(2,4,1)
plot(w,abs(hlbf));
title('lpf using blackman window');
xlabel('w');
ylabel('magnitude of lpf');
grid on
subplot(2,4,2)
plot(w,abs(hlhmf),'linewidth',2);
title('lpf using hamming window');
xlabel('w');
ylabel('magnitude of lpf');
subplot(2,4,3)
plot(w,abs(hlhnf),'linewidth',4);
title('lpf using hanning window');
xlabel('w');
ylabel('magnitude of lpf');
subplot(2,4,4)
plot(w,abs(hlhrf),'linewidth',6);
title('lpf using boxcar');
xlabel('w');
ylabel('magnitude of lpf');
subplot(2,4,5)
plot(w,angle(hlbf));
xlabel('w');
ylabel('phase of lpf');
grid on
subplot(2,4,6)
plot(w,angle(hlhmf),'linewidth',2);
xlabel('w');
ylabel('phase of lpf');
grid on
subplot(2,4,7)
plot(w,angle(hlhnf),'linewidth',4);
xlabel('w');
ylabel('phase of lpf');
grid on
subplot(2,4,8)
plot(w,angle(hlhrf),'linewidth',6);
xlabel('w');
ylabel('phase of lpf');
grid on
13butterworth band pass
Rs=input('Accepted ripples in passband in dB : ');
Rp=input('Accepted ripples in stopband in dB : ');
Fs=input('Stopband frequncy in Hz : ');
Fp=input('Passband frequncy in Hz : ');
F=input('Enter sampling frequency : ');
Ws=2*Fs/F; %Normalized edge frequencies
Wp=2*Fp/F;
[n,Wn]=buttord(Wp,Ws,Rp,Rs);
[b,a] = butter(n,Wn); %[b,a] = butter(n,Wn,'ftype')
w=0:0.001:pi;
[h,w] = freqz(b,a,w);
Magh=abs(h);
MagdB=20*log10(Magh);
Phang=angle(h);
plot(w/pi,MagdB);
title('Magnitude Plot of Butterworth Filter (PassBand) in dB');
xlabel('Normalized Frequency (Hz)');
ylabel('Magnitude (dB)');
14
HPF
N=7;
w=0:0.01:pi;
n=0:1:N-1;
eps=0.001;
alpha=(N-1)/2;
wc1=pi/3;
wc2=(2*pi)/3;
A=sin(wc1*(n-alpha+eps));
B=sin(wc2*(n-alpha+eps));
C=sin(pi*(n-alpha+eps));
D=pi*(n-alpha+eps);
hl=A./D;
hh=(C-B)./D;
hbs=(A-B+C)./D;
hbp=(B-A)./D;
wb=blackman(N);
whm=hamming(N);
whn=hanning(N);
wr=boxcar(N);%boxcar fn is which is zero over entire real line except an interval at which it equals A
hhb=hh.*transpose(wb);
hhhm=hh.*transpose(whm);
hhhn=hh.*transpose(whn);
hhhr=hh.*transpose(wr);
hhbf=freqz(hhb,1,w);
hhhmf=freqz(hhhm,1,w);
hhhnf=freqz(hhhn,1,w);
hhhrf=freqz(hhhr,1,w);
subplot(2,4,1)
plot(w,abs(hhbf));
title('hpf using blackman window');
xlabel('w');
ylabel('magnitude of hpf');
grid on
subplot(2,4,2)
plot(w,abs(hhhmf),'linewidth',2);
title('hpf using hamming window');
xlabel('w');
ylabel('magnitude of hpf');
subplot(2,4,3)
plot(w,abs(hhhnf),'linewidth',4);
title('hpf using hanning window');
xlabel('w');
ylabel('magnitude of hpf');
subplot(2,4,4)
plot(w,abs(hhhrf),'linewidth',6);
title('hpf using boxcar');
xlabel('w');
ylabel('magnitude of hpf');
subplot(2,4,5)
plot(w,angle(hhbf));
xlabel('w');
ylabel('phase of hpf');
grid on
subplot(2,4,6)
plot(w,angle(hhhmf),'linewidth',2);
xlabel('w');
ylabel('phase of hpf');
grid on
subplot(2,4,7)
plot(w,angle(hhhnf),'linewidth',4);
xlabel('w');
ylabel('phase of hpf');
grid on
subplot(2,4,8)
plot(w,angle(hhhrf),'linewidth',6);
xlabel('w');
ylabel('phase of hpf');
grid on
15 quant
t=0:0.0005:1/60;
y=sin(2*pi*60*t);
subplot(4,1,1)
plot(t,y);
xlabel('t');
ylabel('Magnitude');
t1000=0:1/1000:1/60;
n1000=0:length(t1000)-1;
x1000=sin(2*pi*60/1000*n1000);
subplot(4,1,2)
stem(n1000,x1000);
xlabel('n');
ylabel('Magnitude');
l=-1.125:0.125:1.125;
for n=1:18
lmid(n)=(l(n)+l(n+1))/2;
end
for i=1:17
for j=1:17
if (lmid(j)<x1000(i) & x1000(i)<=lmid(j+1))
xq1000(i)=(lmid(j)+lmid(j+1))/2;
end
end
end
for h=1:17
d(h)=abs(abs(x1000(h))-abs(xq1000(h)));
end
subplot(4,1,3)
stem(n1000,xq1000);
xlabel('n');
ylabel('Magnitude');
subplot(4,1,4)
stem(n1000,d);
xlabel('n');
ylabel('Magnitude');
16dft idft
x=input('Enter the input sequence : ');
N=input('Enter the value of N : ');
if length(x)<N
x=[x zeros(1,(N-length(x)))];
end
w=exp(-2*pi*i/N);
for n=1:N
for k=1:N
W(n,k)=w.^((n-1)*(k-1));
end
end
X=W*x';
n=0:N-1;
subplot(2,2,1),stem(n,x);
title('Zero Padded Discrete Time Signal x[n]');
xlabel('n');
ylabel('Amplitude');
subplot(2,2,2);
stem(n,abs(X'));
title('Magnitude Plot of DFT of x[n] : X(k)');
xlabel('Frequency');
ylabel('Amplitude');
subplot(2,2,3);
stem(n,angle(X'));
title('Phase Plot of DFT of x[n] : X(k)');
xlabel('Frequency');
ylabel('Amplitude');
w=exp(2*pi*i/N);
for n=1:N
for k=1:N
W(n,k)=w.^((n-1)*(k-1));
end
end
x=(W*X)/N;
n=0:N-1;
subplot(2,2,4);
stem(n,x');
title('iDFT Plot of DFT of x[n]');
xlabel('n');
ylabel('Amplitude');
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.