Signals and Systems Integrated Lab
Exp. 1: Generation of Elementary Signals in Continuous and Discrete time
Unit Impulse- continuous Unit Impulse- Discrete
clc; clc;
close; close;
clear; clear;
L =5; L =5;
n = - L:0.001 : L; n = - L : L;
x x =[zeros(1,L),ones(1,1),zeros(1,L)];
=[zeros(1,L*1000),ones(1,1),zeros(1,L*1000)]; plot2d3(n,x);
plot(n,x); xlabel('samples');
xlabel('time'); ylabel('amplitude');
ylabel('amplitude'); title('unit impulse');
title('unit impulse');
Unit step- continuous Unit step- discrete
clc; clc;
close; close;
clear; clear;
L=5; L=5;
n=-5:0.01:5; n=-L:L;
x=[zeros(1,L*100),ones(1,L*100+1)]; x=[zeros(1,L ),ones(1,L+1)];
plot(n,x); plot2d3(n,x);
xlabel('time'); xlabel('sample');
ylabel('amplitude'); ylabel('amplitude');
title('unit step'); title('unit step');
Unit ramp- continuous Unit ramp- discrete
clc; clc;
close; close;
clear; clear;
L=5; L=5;
n=-L:0.01:L; n=-L:L;
x=[zeros(1,L*100),0:0.01:L]; x=[zeros(1,L),0:L];
plot(n,x); plot2d3(n,x);
xlabel('time'); xlabel('sample');
ylabel('amplitude') ylabel('amplitude')
title('unit ramp'); title('unit ramp');
Unit Parabolic-Continuous Unit Parabolic-Discrete
clc; clc;
close; close;
clear; clear;
n=0:0.01:10; n=0:10;
x=0.5*(n.^2); x=0.5*(n.^2);
plot(n,x); plot2d3(n,x);
xlabel('sample'); xlabel('sample');
ylabel('amplitude') ylabel('amplitude')
title('unit parabolic'); title('unit parabolic');
Exponential-Continuous Exponential-Discrete
clc; clc;
close; close;
clear; clear;
n=-10:0.01:10; n=-10:10;
a=-0.8; a=0.8;
x1=exp(a*n); x1=a.^n;
subplot(1,2,1); subplot(2,2,1);
plot(n,x1); plot2d3(n,x1);
xlabel('sample'); xlabel('sample');
ylabel('amplitude') ylabel('amplitude')
title('exponental'); title('0<a<1');
b=0.8; b=1.5;
x2=exp(b*n); x2=b.^n;
subplot(1,2,2); subplot(2,2,2);
plot(n,x2); plot2d3(n,x2);
xlabel('sample'); xlabel('sample');
ylabel('amplitude') ylabel('amplitude')
title('exponental'); title('b>1');
c=-0.8;
x3=a.^n;
subplot(2,2,3);
plot2d3(n,x3);
xlabel('sample');
ylabel('amplitude')
title('-1<c<0');
d=-1.5;
x4=b.^n;
subplot(2,2,4);
plot2d3(n,x4);
xlabel('sample');
ylabel('amplitude')
title('-1<d');
Rectangular Function-Continuous Rectangular Function-Discrete
clc; clc;
close; close;
clear; clear;
n=-5:0.01:5; L=5;
x=[zeros(1,400),ones(1,201),zeros(1,400)]; n=-L:L;
plot(n,x); x =[zeros(1,L-1),ones(1,3),zeros(1,L-1)];
xlabel('time'); plot2d3(n,x);
ylabel('amplitude'); xlabel('samples');
title(‘rectagular’); ylabel('amplitude');
title(‘rectangular’);
Sin Function-Continuous Cos Function-Discrete
clc; clc;
close; close;
clear; clear;
t=-0.05:0.001:0.05; n=-0.05:0.001:0.05;
a=2; a=2;
f=100; f=100;
x=a*sin(2*%pi*f*t); x=a*cos(2*%pi*f*n);
plot(t,x); plot2d3(n,x);
xlabel('time'); xlabel('sample');
ylabel('amplitude'); ylabel('amplitude');
title(‘sinusoidal’); title('unit impulse');
Exp. 2: Operation on signals
Sin Function-Continuous-Addition
clc; clc;
close; close;
clear; clear;
t=-0.05:0.001:0.05; t=-0.05:0.001:0.05;
a1=2; a1=2;
a2=3; a2=3;
f1=100; f1=100;
f2=200; f2=200;
x1=a1*sin(2*%pi*f1*t); x1=a1*sin(2*%pi*f1*t);
x2=a2*sin(2*%pi*f2*t); x2=a2*cos(2*%pi*f2*t);
subplot(2,2,1); subplot(2,2,1);
plot(t,x1); plot(t,x1);
xlabel('time'); xlabel('time');
ylabel('amplitude'); ylabel('amplitude');
title('x1'); title('x1');
subplot(2,2,2); subplot(2,2,2);
plot(t,x2) plot(t,x2)
xlabel('time'); xlabel('time');
ylabel('amplitude'); ylabel('amplitude');
title('x2'); title('x2');
x3=x1+x2; x3=x1+x2;
subplot(2,2,3); subplot(2,2,3);
plot(t,x3); plot(t,x3);
xlabel('time'); xlabel('time');
ylabel('amplitude'); ylabel('amplitude');
title('x3'); title('x3');
x4=x1-x2;
subplot(2,2,4);
plot(t,x4);
xlabel('time');
ylabel('amplitude');
title('x4');
Amplitude scaling
Addition, Multiplication
//Xa( t ) = 1 ; 0<t <1 clc;
//2 ; 1<t <2; clear;
// 1 ; 2<t <3 close;
// Xb( t ) = t ; 0<t <1 x=input('Enter the input seuence:');
// 1 ; 1<t <2; a=input('Enter amplitude reversal factor:');
// 3−t ; 2<t <3 y1=a*x;
n=length(x);
clc; subplot(2,2,1);
clear; plot2d3(0:n-1,x);
close; xlabel('n');
t=-1:0.001:5; ylabel('Amplitude');
x1=1; title('input sequence');
x2=2; subplot(2,2,2);
x3=3-t; plot2d3(0:n-1,y1);
xa=x1.*(t>0&t<1)+x2.*(t>=1&t<=2)+x1.*(t> xlabel('n');
2&t<3); ylabel('Amplitude');
xb=t.*(t>0&t<1)+x1.*(t>=1&t<=2)+x3.*(t>2 title('Amplitude reversed signal');
&t<3);
xadd=xa+xb;
xmul=xa.*xb;
subplot(2,3,1);
plot(t,xa);// P l o t s i n p u t s i g n a l xa
xlabel('t');
ylabel('Amplitude');
title('i n p u t s i g n a l xa ');
subplot(2,3,2);
plot(t,xb);// P l o t s i n p u t s i g n a l xb
xlabel('t');
ylabel('Amplitude');
title('i n p u t s i g n a l xb');
subplot(2,3,3);
plot(t,xadd);// P l o t s a d d i t i o n of s i g n a l
xa and xb
xlabel('t');
ylabel('Amplitude');
title('A d di ti o n of two s i g n a l s , xadd ');
subplot(2,3,4);
plot(t,xmul);// P l o t s M u l t i p l i c a t i o n of
s i g n a l xa and xb
xlabel('t');
ylabel('Amplitude');
title('M u l t i p l i c a t i o n of two s i g n a l s ,
xmul ');
Even and Odd
Time shifting
clc; clc;
clear; clear;
close; close;
x=input('Enter the input seuence:'); t=0:0.005:4*%pi;
a=input('Enter the positive shift:'); x=sin(t)+cos(t);
b=input('Enter the negative shift:'); subplot(2,2,1);
n=length(x); plot(t,x);
i=a:n+a-1; xlabel('t');
j=b:n+b-1; ylabel('Amplitude');
subplot(2,2,1); title('signal');
plot2d3(0:n-1,x); y=sin(-t)+cos(-t);
xlabel('n'); subplot(2,2,2);
ylabel('Amplitude'); plot(t,y);
title('input sequence'); xlabel('t');
subplot(2,2,2); ylabel('Amplitude');
plot2d3(i,x); title('Reversed signal');
xlabel('n'); z=x+y;
ylabel('Amplitude'); subplot(2,2,3);
title('Positive shifted signal'); plot(t,z/2);
subplot(2,2,3); xlabel('t');
plot2d3(j,x); ylabel('Amplitude');
xlabel('n'); title('Even signal');
ylabel('Amplitude'); z1=x-y;
title('Negative shifted signal'); subplot(2,2,4);
plot(t,z1/2);
xlabel('t');
ylabel('Amplitude');
title('Odd signal');
Even and Odd Convolution-discrete
clc;
//Xa( t ) = 1 ; 0<t <1 close;
//2 ; 1<t <2; clear;
// 1 ; 2<t <3 x1=input('enter the first sequence:');
// Xb( t ) = t ; 0<t <1 x2=input('enter the second sequence:');
// 1 ; 1<t <2; y=conv(x1,x2);
// 3−t ; 2<t <3 subplot(2,2,1);
plot2d3(x1);
clc; xlabel('n');
clear; ylabel('Amplitude');
close; title('First sequence');
t=-1:0.001:5; subplot(2,2,2);
x1=1; plot2d3(x2);
x2=2; xlabel('n');
x=x1.*(t>0&t<1)+x2.*(t>=1&t<=2)+x1.*(t>2 ylabel('Amplitude');
&t<3); title('Second sequence');
y=x1.*(t>-1&t<0)+x2.*(t>=-21&t<=- subplot(2,2,3);
1)+x1.*(t>-3&t<-2); plot2d3(y);
subplot(2,3,1); xlabel('n');
plot(t,x);// P l o t s i n p u t s i g n a l xa ylabel('Amplitude');
xlabel('t'); title('Convoluted sequence');
ylabel('Amplitude'); disp('The convolved sequence is');
title('i n p u t s i g n a l xa '); disp(y);
subplot(2,3,2);
plot(t,y);// P l o t s i n p u t s i g n a l xb
xlabel('t');
ylabel('Amplitude');
title('i n p u t s i g n a l xb');
z=x+y;
subplot(2,3,3);
plot(t,z);// P l o t s a d d i t i o n of s i g n a l xa
and xb
xlabel('t');
ylabel('Amplitude');
title('A d di ti o n of two s i g n a l s ');
subplot(2,3,4);
a=z/2;
plot(t,a);// P l o t s M u l t i p l i c a t i o n of s i
g n a l xa and xb
xlabel('t');
ylabel('Amplitude');
title('Even signal');
z1=x-y;
subplot(2,3,5);
plot(t,z1);// P l o t s a d d i t i o n of s i g n a l
xa and xb
xlabel('t');
ylabel('Amplitude');
title('Subtraction of two s i g n a l s ');
subplot(2,3,6);
b=z1/2;
plot(t,b);// P l o t s M u l t i p l i c a t i o n of s i
g n a l xa and xb
xlabel('t');
ylabel('Amplitude');
title('Odd signal');
Convolution-Continuous
//Xa( t ) = 1 ; 0<t <1
//
// Xb( t ) = 1 ; 0<t <1
clc;
clear;
close;
t=-2:0.001:5;
x=0.*(t<0)+1.*(t>=0&t<=1);
y=0.*(t<0)+1.*(t>=0&t<=1);
subplot(2,2,1);
plot(t,x);// P l o t s i n p u t s i g n a l xa
xlabel('t');
ylabel('Amplitude');
title('i n p u t s i g n a l x ');
subplot(2,2,2);
plot(t,y);// P l o t s i n p u t s i g n a l xb
xlabel('t');
ylabel('Amplitude');
title('i n p u t s i g n a l y');
z=conv(x,y);
subplot(2,2,3);
t1=-4:0.001:10;
plot(t1,z);// P l o t s a d d i t i o n of s i g n a l
xa and xb
xlabel('t');
ylabel('Amplitude');
title('Convolved signal');