Signal System Matlab
Signal System Matlab
1
Aim:- To plot continuous time signal encountered in signal processin like sine
square ,sawtooth ,exponential sequences using matlab.
Matlab code
1.Sinusoidal wave form
clc;
clear all;
close all;
T=2;
t=2:0.1:10;
x1=sin((2*pi*t)/T);
subplot(3,2,1),plot(x1);
xlabel('t'),ylabel('x1');
tilte('sinusoidal waveform');
4.Exponential waveform
clc;
clear all;
close all;
t1=5:.01:10;
x=exp(t1);
plot(x);
xlabel('t'),ylabel('x');
titlte('exponenetial waveform');
5.cosine waveform
clc;
clear all;
close all;
T=2;
t=2:0.1:10;
x1=cos((2*pi*t)/T);
subplot(3,2,1),plot(x1);
xlabel('t'),ylabel('x1');
tilte('sinusoidal waveform');
sinusoidal waveform
1
0.8
0.6
0.4
0.2
x1
-0.2
-0.4
-0.6
-0.8
-1
0 10 20 30 40 50 60 70 80 90
t
Square waveform
1
0.8
0.6
0.4
0.2
x2
-0.2
-0.4
-0.6
-0.8
-1
0 200 400 600 800 1000 1200
t2
Sawtooth waveform
1
0.8
0.6
0.4
0.2
0
x
-0.2
-0.4
-0.6
-0.8
-1
0 500 1000 1500 2000 2500
t
Exponential waveform
4
x 10
2.5
1.5
x
0.5
0
0 100 200 300 400 500 600
t
Cosine waveform
1
0.8
0.6
0.4
0.2
x1
-0.2
-0.4
-0.6
-0.8
-1
0 10 20 30 40 50 60 70 80 90
t
Experiment no. 2
Object:- To plot discrete time signals encountered in signal processing like unit impulse,
Unit step, ramp and exponential sequences using MATLAB.
Matlab Code:-
Theory:- Even and odd signals bear some important symmetrical properties,
under
reversal of independent variable, these signal remains the same (even) or
get reflected or flipped (odd signal) about the horizontal axis, equation
5.1 and 5.2 reveled the both continuous and discrete time cases.
Matlab Code:-
clc;
close all;
clear all;
n=-3:3;
xn=[0 0 0 1 1 1 1];
xN=fliplr(xn);
xe=(xn+xN)/2;
xo=(xn-xN)/2;
subplot(3,1,1);stem(n,xn);axis([-4 4 -1 1.5])
grid;ylabel('x[n]')
title('demonstration of even odd decomposition')
subplot(3,1,2);stem(n,xe);axis([-4 4 -1 1.5])
grid;ylabel('xe[n]')
subplot(3,1,3);stem(n,xo);axis([-4 4 -1 1.5])
grid;ylabel('xo[n]');xlabel('n')
Output/ Result:
Experiment no. 4
Object:- To explore the effect of transformation of signal parameters (time
shifting and time scalling)
Matlab Code:-
Time Shifting
clc;
clear all;
close all;
n=0:20;
xn=[0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0];
subplot(2,1,1);stem(n,xn);axis([-1 26 0 11])
xlabel('n');ylabel('x[n]');title('x[n]versus n')
subplot(2,1,2);stem(n+5,xn);axis([-1 26 0 11])
xlabel('n');ylabel('x[n]');title('x[n-5]versus n')
Time Scalling
clc;
clear all;
close all;
n=0:20;
xn=[0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0];
nnew=0:40;
yn=zeros(1,41);
yn(1:2:41)=xn;
subplot(2,1,1);stem(n,xn);axis([-2 42 -1 11])
xlabel('n');ylabel('x[n]');
subplot(2,1,2);stem(nnew,yn);axis([-2 42 -1 11])
xlabel('nnew');ylabel('x[n]');
Output/ Result:- Time Shifting
Time Scalling
EXPERIMENT NO. 5
Object:-
Find out the circular convolution y (n) of two given sequences:-
1. x(n) = [10 20 30 40 50 60] and
2. h(n) = [5 6 7 8 9 10] .
Matlab Code :-
clc;
clear all;
close all;
x=[10 20 30 40 50 60];
h=[5 6 7 8 9 10];
nx=(0:1:5);
nh=(0:1:5);
subplot(3,1,1);stem(nx,x);
xlabel('n');ylabel('x[n]');
subplot(3,1,2);stem(nh,h);
xlabel('n');ylabel('h[n]');
n=(0:1:length(x)+length(h)-2); %total length of colum start from 0 with interval
1 and up to length of sequence x which is 06 here and length of sequence h
which is 6
%here - 2 = 04 total 10
subplot(3,1,3);
c=conv(x,h);
stem(n,c,'k');
xlabel('n');ylabel('x[n]');
title('circular convolution of wo sequences');
Output/ Result:-
EXPERIMENT NO. 6
Object:- 1.To explore the causality and non causality of the system.
1. For the given rational form transfer function (�)=2+16 �−1+44 �−2+56 �−3+32
�−4/3+3 �−1−15 �−2+18 �−3−12 �−4
a. Determine location of poles and zeroes and convert into factored form.
b. Plot pole-zero diagram.
c. Find the possible ROCs and discuss the stability of the system.
Matlab Code :-
Z = 2S4 + 16S3 + 44S2 + 56S + 32
----------------------------------------
3S4 + 3S3 - 15S2 + 18S – 12
1. clc;
clear all;
n=[2,16,44,56,32];
d=[3,3,-15,18,-12];
sys=tf(n,d)
2.
clc;
clear all;
num=[2,16,44,56,32];
den=[3,3,-15,18,-12];
[z, p, k] = tf2zp (num, den)
zplane(num,den)
title('pole zero plot')
Result:-
z=
-4.0000 + 0.0000i
-2.0000 + 0.0000i
-1.0000 + 1.0000i
-1.0000 - 1.0000i
p=
-3.2361 + 0.0000i
1.2361 + 0.0000i
0.5000 + 0.8660i
0.5000 - 0.8660i
k=0.6667
Factored Form:-
�(�)=0.667(1+4 �−1)(1+2 �−1)(1+(1−�) �−1)(1+(1+�) �−1)(1+3.236 �−1)(1−1.236
�−1)(1−(0.5+0.866�) �−1)(1−(0.5−0.866�) �−1)
Possible ROC’s and Stability of the system will be:-
1. |z| < 1 The system will be unstable, since it will not include the unit circle.
2. 1 < |z| < 1.236 The system will be unstable, since it will not include the unit circle.
3. 1.236 < |z| < 3.236 The system will be unstable, since it will not include the unit
circle.
4. |z| > 3.236 The system will be unstable, since it will not include the unit circle.
OUTPUT:-
Experiment no. 7
Object:- To determine the magnitude and phase response of Fourier transform of
given signal.
Matlab Code :-
clc;
clear all;
close all;
t=-1.5:0.005:1.5;
xsin=sin(2*pi*t);
xt=xsin>0;
k=-50:50;
T=1;T1=0.25;w0=2*pi/T;t0=0.25;
ak=exp(-j*k*w0*t0).*sin(k*2*pi*(T1/T))./(k*pi);
ak(51)=2*T1/T;
bk=fliplr(ak);
xtr=zeros(1,length(t));
for k=-50:50
xtr=xtr+ ak(k+51)*exp(j*k*w0*t);
end
yt=zeros(1,length(t));
for k=-50:50
yt=yt+ bk(k+51)*exp(j*k*w0*t);
end
figure(1);set(gcf,'defaultaxesfontsize',8)
subplot(3,1,1);plot(t,xt);ylabel('x(t)')
title('periodic square wave (T=1,T1=0.25)')
set(gca,'ylim',[-0.2 1.2]);grid
subplot(3,1,2);plot(t,xtr);ylabel('x(t)')
title('periodic square wave reconstructed from its FS')
set(gca,'ylim',[-0.2 1.2]);grid;
subplot(3,1,3);plot(t,real(yt))
xlabel('t');ylabel('y(t)=x(-t)')
title('reconstruction from bk''s with 101 terms')
set(gca,'ylim',[-0.2 1.2]);grid
Output/ Result:-