Sie sind auf Seite 1von 30

EXPERIMENT NO.

01
OBJECT-To study addition and multiplication of two sequence. APPARATUS REQUIRED-MATLAB software 1-For additionM-Codea=[1 5 7] b=[3 6 8] c=a+b

Simulationa= 1 b= 3

Resultc= 4 11 15

2-For MultiplicationM-Codea=[1 2 5] b=[3 6 9] c=a*b

Simulationa= 1 2 5

b= 3 6 9

Resultc= 18 36 80

EXPERIMENT NO.-2
OBJECT-To study multiplication of matrix.
APPARATUS REQUIRED-MATLAB software

M-Codea=[1 3 7;6 7 8;3 4 5] b=[2 5 7;8 4 6;4 7 5] c=[3 5 9;1 3 6;3 4 3] d=a*b*c

Simulationa= 1 6 3 3 7 4 7 8 5

b= 2 8 4 5 4 7 7 6 5

c= 3 1 3 5 3 4 9 6 3

Resultd= 408 786 450 708 1338 768 1062 1956 1128

EXPERIMENT NO.03
OBJECT:- Evaluate 4 point DFT of x(n)=1 for 0n3,0 elsewhere.

APPRATUS REQURIED:- MATLAB software M-CODE:x=[1,1,1,1] y=fft(x) plot(y,'*') x label('real axis') y label('imaginary axis')

SIMULATION:x= 1 1 1 1

y= 4 0 0 0

RESULT:4 3.5 3 2.5 2 1.5 1 0.5 0

1.5

2.5

3.5

EXPERIMENT NO.04

OBJECT:- Evaluate 4 point IDFT of x(n)=[1,1,1,1 ].

APPRATUS REQURIED:- MATLAB software . M-CODE:x=[1,1,1,1] y=ifft(x) plot(y,'*') x label('real axis') y lable('imaginary axis')

SIMULATION:x= 1 1 1 1

y= 1 0 0 0

RESULT:1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0

1.5

2.5

3.5

EXPERIMENT NO.-05 OBJECT- To add sine waves and cosine waves of different
frequencies.

APPARATUS REQUIRED- MATLAB software . 1.FOR SINE WAVES:M-CODEfs=100; t=[1:100]/fs a1=input('Enter the value of amplitude='); a2=input('Enter the value of amplitude='); a3=input('Enter the value of amplitude='); s1=a1*sin(2*pi*t*5); s2=a2*sin(2*pi*t*15); s3=a3*sin(2*pi*t*30); subplot(2,2,1); plot(s1); xlabel('time(sec)'); ylabel('amplitude'); title('sine wave of frequency-5') subplot(2,2,2); plot(s2); xlabel('time(sec)'); ylabel('amplitude'); title('sine wave of frequency-15') subplot(2,2,3); plot(s3); xlabel('time(sec)'); ylabel('amplitude'); title('sine wave of frequency-30') s4=s1+s2+s3; plot(s4); xlabel('time(sec)'); ylabel('amplitude'); title('sine wave after addition of three sine waves')

SIMULATIONEnter the value of amplitude=5 Enter the value of amplitude=15 Enter the value of amplitude=30

RESULT-

sine wave of frequency-5 5 20 10

sine wave of frequency-15

amplitude

amplitude
0

0 -10

50 100 time(sec) sine wave after addition of three sine waves 50

-5

-20

50 time(sec)

100

amplitude

-50

50 time(sec)

100

2.FOR COSINE WAVES:M-CODEfs=100; t=[1:100]/fs a1=input('Enter the value of amplitude='); a2=input('Enter the value of amplitude='); a3=input('Enter the value of amplitude='); s1=a1*cos(2*pi*t*5); s2=a2*cos(2*pi*t*15); s3=a3*cos(2*pi*t*30); subplot(2,2,1); plot(s1); xlabel('time(sec)'); ylabel('amplitude'); title('cos wave of frequency-5') subplot(2,2,2); plot(s2); xlabel('time(sec)'); ylabel('amplitude'); title('cos wave of frequency-15') subplot(2,2,3); plot(s3); xlabel('time(sec)'); ylabel('amplitude'); title('cos wave of frequency-30') s4=s1+s2+s3; plot(s4); xlabel('time(sec)'); ylabel('amplitude'); title('cos wave after addition of three cosine waves')

SIMULATIONEnter the value of amplitude=5 Enter the value of amplitude=15 Enter the value of amplitude=30

RESULT-

cos wave of frequency-5 5 20 10

cos wave of frequency-15

amplitude

amplitude
0

0 -10

50 100 time(sec) cos wave after addition of three cosine waves 50

-5

-20

50 time(sec)

100

amplitude

-50

50 time(sec)

100

EXPERIMENT NO.-06

OBJECT- To add sinc waves and sawtooth waves of different


frequencies.

APPARATUS REQUIRED- MATLAB software . 1.FOR SINC WAVES:M-CODEfs=100; t=[1:100]/fs a1=input('Enter the value of amplitude='); a2=input('Enter the value of amplitude='); a3=input('Enter the value of amplitude='); s1=a1*sinc(2*pi*t*5); s2=a2*sinc(2*pi*t*15); s3=a3*sinc(2*pi*t*30); subplot(2,2,1); plot(s1); xlabel('time(sec)'); ylabel('amplitude'); title('sinc wave of frequency-5') subplot(2,2,2); plot(s2); xlabel('time(sec)'); ylabel('amplitude'); title('sinc wave of frequency-15') subplot(2,2,3); plot(s3); xlabel('time(sec)'); ylabel('amplitude'); title('sinc wave of frequency-30') s4=s1+s2+s3; plot(s4); xlabel('time(sec)'); ylabel('amplitude'); title('sinc wave after addition of three sinc waves')

SIMULATIONEnter the value of amplitude=5 Enter the value of amplitude=15 Enter the value of amplitude=30

RESULT-

sinc wave of frequency-5 6 4 1 0.5

sinc wave of frequency-15

amplitude

2 0 -2

amplitude
0

0 -0.5 -1

50 100 time(sec) sinc wave after addition of three sinc waves 4 2

50 time(sec)

100

amplitude

0 -2 -4

50 time(sec)

100

2.FOR SAWTOOTH WAVES:M-CODEfs=100; t=[1:100]/fs a1=input('Enter the value of amplitude='); a2=input('Enter the value of amplitude='); a3=input('Enter the value of amplitude='); s1=a1*sawtooth(2*pi*t*5); s2=a2*sawtooth(2*pi*t*15); s3=a3*sawtooth(2*pi*t*30); subplot(2,2,1); plot(s1); xlabel('time(sec)'); ylabel('amplitude'); title('sawtooth wave of frequency-5') subplot(2,2,2); plot(s2); xlabel('time(sec)'); ylabel('amplitude'); title('sawtooth wave of frequency-15') subplot(2,2,3); plot(s3); xlabel('time(sec)'); ylabel('amplitude'); title('sawtooth wave of frequency-30') s4=s1+s2+s3; plot(s4); xlabel('time(sec)'); ylabel('amplitude'); title('sawtooth wave after addition of three sawtooth waves')

SIMULATIONEnter the value of amplitude=5 Enter the value of amplitude=15 Enter the value of amplitude=30

RESULT-

sawtooth wave of frequency-5 5 20 10

sawtooth wave of frequency-15

amplitude

amplitude
0

0 -10

-20 50 100 0 time(sec) sawtooth wave after addition of three sawtooth waves 50

-5

50 time(sec)

100

amplitude

-50

50 time(sec)

100

EXPERIMENT NO. -7
OBJECT- To implement the filter function. APPARATUS REQUIRED- MATLAB software. M-CODEfs=20000; %sampling rate F=[3000 4000 6000 8000]; %band limits A=[0 1 0]; %band type:0='stop',1='pass' dev=[0.0001 10^(0.1/20)-1 0.0001]; %ripple/attenuation spec [M,Wn,beta,typ]=kaiserord(F,A,dev,fs); %window parameters b=fir1(M,Wn,typ,kaiser(M+1,beta),'noscale'); %filter design plot(b)

RESULT0.25 0.2 0.15 0.1 0.05 0 -0.05 -0.1 -0.15 -0.2 -0.25

20

40

60

80

100

120

Experiment :8 Object:- To study the circular convolution . Apparatus required :- Matlab software .

M Code:clc; clear all; close all; disp('circular convolution program'); x=input('enter i/p x(n):'); m=length(x); h=input('enter i/p sequence h(n)'); n=length(h); subplot(2,2,1), stem(x); title('i/p sequencce x(n)is:'); xlabel('---->n'); ylabel('---->x(n)');grid; subplot(2,2,2), stem(h); title('i/p sequencce h(n)is:'); xlabel('---->n'); ylabel('---->h(n)');grid; disp('circular convolution of x(n) & h(n) is y(n):'); if(m-n~=0) if(m>n) h=[h,zeros(1,m-n)]; n=m; endx=[x,zeros(1,n-m)]; m=n; end

y=zeros(1,n); y(1)=0; a(1)=h(1); for j=2:n a(j)=h(n-j+2); end %ciruclar conv for i=1:n y(1)=y(1)+x(i)*a(i); end for k=2:n y(k)=0; % circular shift for j=2:n 2(j)=a(j-1); end x2(1)=a(n); for i=1:n if(i<n+1) a(i)=x2(i); y(k)=y(k)+x(i)*a(i); end end end ysubplot(2,2,[3,4]),stem(y); title('convolution of x(n) & h(n) is:'); xlabel('---->n'); ylabel('---->y(n)');grid;

Simulation:Enter the length of the first sequence 4 Enter the length of the second sequence 3 Enter the first sequence 1 2 3 4 Enter the second sequence 1 2 3 The circular convolution is 18 16 10 16

Result:-

EXPERIMENT NO: - 09
OBJECT:- TO write a MATLAB program to compute linear
convolution of two given Sequences.

APPARATUS REQUIRED:- MATLAB SOFTWARE. M-CODE:clc; clear all; close; disp('enter the length of the first sequence m='); m=input(''); disp('enter the length of first sequence x[m]='); for i=1:m x(i)=input(''); end disp('enter the length of the second sequence n='); n=input(''); disp('enter the length of second sequence h[n]='); for j=1:n h(j)=input(''); end y=conv(x,h); figure; subplot(3,1,1); stem(x); ylabel ('amplitude---->'); xlabel('n---->'); title('x(n) Vs n'); subplot(3,1,2); stem(h); ylabel('amplitude---->'); xlabel('n---->'); title('h(n) Vs n'); subplot(3,1,3);

stem(y); ylabel('amplitude---->'); xlabel('n---->'); title('y(n) Vs n'); disp('linear convolution of x[m] and h[n] is y');

SIMULATION:Enter the length of the first sequence m= 6 Enter the length of first sequence x[m]= 1 2 3 4 5 6 Enter the length of the second sequence n= 6 Enter the length of second sequence h[n]= 1 2 3 4 5 6

RESULT:Linear convolution of x[m] and h[n] is


x(n) Vs n

amplitude---->

10 5 0 1 1.5 2 2.5 3 3.5 n----> h(n) Vs n 4 4.5 5 5.5 6

amplitude---->

10 5 0 1 1.5 2 2.5 3 3.5 n----> y(n) Vs n 4 4.5 5 5.5 6

amplitude---->

100 50 0 1 2 3 4 5 6 n----> 7 8 9 10 11

EXPERIMENT NO: - 10
OBJECT:- TO write a MATLAB program to Amplitude and
frequency response of Butter worth Low pass filter.

APPARATUS REQUIRED:- MATLAB Software. M-CODE:clc; close all; clear all; format long; 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'); [z,p,k]= butter(n,wn); [b,a]=butter(n,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); ylabel('gain in db--------->'); xlabel('(a) normalized freq------>'); subplot(2,1,2); plot(om/pi,an); ylabel('phase in db--------->'); xlabel('(b) normalized freq------>');

SIMULATION:enter the passband ripple enter the stopband ripple enter the passband frequency enter the stopband frequency enter the sampling frequency 15 60 1500 3000 7000

RESULT:0

gain in db--------->

-20

-40

-60

0.1

0.2

0.3

0.4 0.5 0.6 0.7 (a) normalized freq------>

0.8

0.9

phase in db--------->

2 0 -2 -4

0.1

0.2

0.3

0.4 0.5 0.6 0.7 (b) normalized freq------>

0.8

0.9

EXPERIMENT NO: - 11
OBJECT: - TO write a MATLAB program to Amplitude and
frequency response of Butter worth high pass filter .

APPARATUS REQUIRED:- MATLAB Software. M-CODE:clc; close all; clear all; format long; 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'); [z,p,k]= butter(n,wn); [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('(a) normalized freq------>'); subplot(2,1,2); plot(om/pi,an); ylabel('phase in db--------->'); xlabel('(b) normalized freq------>');

SIMULATION:Enter the passband ripple2 Enter the stopband ripple40 Enter the passband frequency2000 Enter the stopband frequency3500 Enter the sampling frequency8000

RESULTS:0

gain in db--------->

-100 -200 -300 -400

0.1

0.2

0.3

0.4 0.5 0.6 0.7 (a) normalized freq------>

0.8

0.9

phase in db--------->

2 0 -2 -4

0.1

0.2

0.3

0.4 0.5 0.6 0.7 (b) normalized freq------>

0.8

0.9

EXPERIMENT NO: - 12

OBJECT: - TO write a MATLAB program to design FIR LP\HP using


triangular window techniques.

APPARATUS REQUIRED:- MATLAB Software. M-CODE:clc; close all; clear all; format long; 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=triang(n1); %Lowpass filter b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,1,1); plot(o/pi,m); ylabel('gain in db---->'); xlabel('Normalised frequency---->');

title('FIR filter using Triangular window of LPF ----'); grid on; %Highpass filter b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,1,2); plot(o/pi,m); ylabel('gain in db---->'); xlabel('Normalised frequency---->'); title('FIR filter using Triangular window of HPF ----'); grid on ;

SIMULATION:enter the passband ripple enter the stopband ripple enter the passband frequency enter the stopband frequency enter the sampling frequency 0.04 0.02 1500 2000 8000

RESULTS:-

FIR filter using Triangular window of LPF ---20

gain in db---->

-20

-40

0.1

0.2

0.4 0.5 0.6 0.7 0.8 Normalised frequency----> FIR filter using Triangular window of HPF ----

0.3

0.9

10

gain in db---->

0 -10 -20 -30

0.1

0.2

0.3

0.4 0.5 0.6 0.7 Normalised frequency---->

0.8

0.9

Das könnte Ihnen auch gefallen