Sie sind auf Seite 1von 21

Department of Physics & Electronics

Rajdhani College
(University of Delhi)

Signal and System


Lab File
(2019-20)
for
B.Sc. (Hons.) Electronics
4rd Sem.

Submitted By: - Submitted to: -


SHAILESH MAHTO Mrs. Chanchal Yadav
18055558031
1. Plot the following signals: (continuous time signal for t = -2𝜋 to 2 𝜋)
a) Y1 = 5sin(t)
b) Y2 = √3sin(t-0.25)
c) Y3 = (1.7)2cos(t/4)
d) Y4 = tan2(t)
Scilab Lab code
clf()
clear;

t=[-2*%pi:0.1:2*%pi];
y1=5*sin(t);
y2=sqrt(3)*sin(t-0.25);
y3=(1.7)^2*cos(t/4);
y4=(tan(t))^2;

subplot(221)
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
plot(t,y1)
title("(a) y1 = 5sin(t)","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-2])
ylabel("signal","fontsize",3,"position",[-1;2])
xgrid;

subplot(224)
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
plot(t,y2)
title("(b) y2 = sqrt3sin(t-0.25)","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-1])
ylabel("signal","fontsize",3,"position",[-1;1])
xgrid;

subplot(222)
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
plot(t,y3)
title("(c) y3 = (1.7)^2cos(t/4)","fontsize",3)
xlabel("time","fontsize",3,"position",[6;0])
ylabel("signal","fontsize",3,"position",[-1;1])
xgrid;

subplot(223)
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
plot(t,y4)
title("(d) y4 = tan2(t) ","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-1])
ylabel("signal","fontsize",3,"position",[-1.5;20000])
xgrid;
Output:
2. Plot the following signals: (discrete time signal for n= -10 to 12)
a) Y1 = 5n2 + 3n
b) Y2 = sin(nΠ/2) + cos(nΠ/4)
c) Y3 = an (for a>1, a= 1, a<1)
Scilab Code:
clc;
n=(-10:0.1:12);
y1=5*n^2+3*n;
y2=sin(%pi*n/2)+cos(%pi*n/2);
a=input('enter the value of a');
y3=a^n
subplot(312);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
plot2d3(n,y1);
title("(a) y1 = 5*n^2+3*n","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-2])
ylabel("signal","fontsize",3,"position",[-1;0.5])

subplot(311);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
plot2d3(n,y2);
p=get("hd1")
p.mark_style=0
title("(b) y2 = sin(%pi*n/2)+cos(%pi*n/2)","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-2])
ylabel("signal","fontsize",3,"position",[-1;2])

subplot(313);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
plot2d3(n,y3);
title("(c) y3 = a^n","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-2])
ylabel("signal","fontsize",3,"position",[-1;0.5])
Output:

For a = 1

For a = 0

For a = -1
3. Plot the following signals: (continuous time signals for t = -L to L+5)
a) Y1 = u[n]
Scilab Code:
clc;
clear;
L = input('Enter the value of L: ');
t = -L:0.01:L+5;
a = input('Enter the value of a ');
x = ones(t).*(t>=a);
plot(t,x);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
title("Y1 = u(t )","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-0.1])
ylabel("signal","fontsize",3,"position",[-1;0.5])
set(gca(),"data_bounds",matrix([-6,6,-0.1,1.1],2,-1));
Console window:

Output:
b) Y2 = u(t-a)
Scilab Code:
clc;
clear;
L = input('Enter the value of L: ');
t = -L:0.01:L+5;
a = input('Enter the value of a ');
x = ones(t).*(t>=a);
plot(t,x);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
title("Y2 = u(t-a )","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-0.1])
ylabel("signal","fontsize",3,"position",[-1;0.5])
set(gca(),"data_bounds",matrix([-6,6,-0.1,1.1],2,-1));
Console window

Output:
c) Y3 = 𝛿(n)
Scilab Code:
clc;
clf;
clear all;
function y=impulse(l, t0)
t=-l:0.1:l;
for i=1:length(t)
if(t(i)==t0)
y(i)=1;
else
y(i)=0;
end
end
endfunction
t= -10:0.1:10
y3=impulse(10,0);
plot(t,y3);
title('y3 versus t','fontsize',3);
xlabel("t","fontsize",3);
ylabel("y3","fontsize",3);
Output:
d) Y4= 𝛿(n+a)
Scilab Code:
clc;
clf;
clear all;
function y=impulse(l, t0)
t=-l:0.1:l;
for i=1:length(t)
if(t(i)==t0)
y(i)=1;
else
y(i)=0;
end
end
endfunction
t= -10:0.1:10
y4=impulse(10,5);
plot(t,y4);
title('y4 versus t','fontsize',3);
xlabel("t","fontsize",3);
ylabel("y4","fontsize",3);
Output:
e) Y5 = sin(t)/t
Scilab Code:
clc;
clear;
L = input('Enter the value of L');
t = [-L:0.01:L+5];
r = sin(t);
y = r./t
plot(t, y, 5);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
title("Y5 = sin(t)/t","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-0.1])
ylabel("signal","fontsize",3,"position",[-1;0.5])
xgrid;
Output:
4. Plot the following signals: (discrete time signal for n=-L-3 to L-2)
a. Y1 = u[n]
Scilab Code:
clc;
clear;
L = input('Enter the value of L: ');
t = -L:0.1:L+5;
a = input('Enter the value of a ');
x = ones(t).*(t>=a);
plot2d3(t,x);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
title("Y1 = u[n]","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-0.1])
ylabel("signal","fontsize",3,"position",[-1;0.5])
set(gca(),"data_bounds",matrix([-6,6,-0.1,1.1],2,-1));

Console window:

Output:
b. Y2 = u[n-b]
Scilab Code:
clc;
clear;
L = input('Enter the value of L: ');
t = -L:0.1:L+5;
a = input('Enter the value of a ');
x = ones(t).*(t>=a);
plot2d3(t,x);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
title("Y2 = u[n-b]","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-0.1])
ylabel("signal","fontsize",3,"position",[-1;0.5])
set(gca(),"data_bounds",matrix([-6,6,-0.1,1.1],2,-1));
Console window:

Output:
c. Y3 = 𝛿[n]
Scilab Code:
clc;
clf;
clear all;
function y=impulse(l, t0)
t=-l:0.1:l;
for i=1:length(t)
if(t(i)==t0)
y(i)=1;
else
y(i)=0;
end
end
endfunction
t= -10:0.1:10
y3=impulse(10,0);
plot2d3(t,y3);
title('y3 versus t','fontsize',3);
xlabel("t","fontsize",3);
ylabel("y3","fontsize",3);
Output:
d. Y4 = 𝛿[n+b]
Scilab Code:
clc;
clf;
clear all;
function y=impulse(l, t0)
t=-l:0.1:l;
for i=1:length(t)
if(t(i)==t0)
y(i)=1;
else
y(i)=0;
end
end
endfunction
t= -10:0.1:10
y4=impulse(10,5);
plot2d3(t,y4);
title('y4 versus t','fontsize',3);
xlabel("t","fontsize",3);
ylabel("y3","fontsize",3);
Output:
e. Y5 = sin(n)/n
Scilab Code:
clc;
clear;
L = input('Enter the value of L');
t = [-L:0.1:L+5];
r = sin(t);
y = r./t
plot2d3(t, y, 5);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
title("Y5 = sin(n)/n","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-0.1])
ylabel("signal","fontsize",3,"position",[-1;0.5])
xgrid;
Output:
5. Plot the following signals: (continuous time signal for t=-7 to 7)
a)

b)

Scilab Code:
clc;
close;
clear all;
t = -7:0.0001:7;
subplot(2,1,1)
y1 = 2*t^2+7;
y2 = 3*t;
y3 = 5*cos(5*t);
y = y1.*(t>4 & t<7) + y2.*(t<-4 & t>-7) + y3.*(t>-4 &t <4);
plot(t,y);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
title("Y1 = 2t2 + 7(For t>=4),=3t(For t<-4),=5cos(πt)(Elsewhere)","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-0.1])
ylabel("signal","fontsize",3,"position",[-1;0.5])
xgrid;
subplot(2,1,2)
y1 = 2*sin(2*%pi*t);
y2 = 3*t-2;
y = y1.*(t>-3 & t<7) + y2.*(t<-3 & t>-7);
plot(t,y);
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
title("Y2 = 2sin(2pi*t)(For t>-3),=3t-2(Elsewhere)","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-0.1])
ylabel("signal","fontsize",3,"position",[-1;0.5])
xgrid;

Output:
6. Plot the following signal using functions.
a. Y1= 2u(t)- 3u(t-2.5)+ u(t+5) (continuous time signal for t=-7 to 8)
b. Y2= 3u[2n+5]-u[n-3]+u[n] (discrete time signal for n=-5 to 5)
Scilab Code:
clc;
clf();
clear;
subplot(2,1,1)
t=-7:0.01:8;
y1=2*ones(t).*(t>0)
y2=3*ones(t).*(t>-2.5)
y3=ones(t).*(t>5)
function [y]=f(y1, y2, y3)
y1=2*ones(t).*(t>0)
y2=3*ones(t).*(t>-2.5)
y3=ones(t).*(t>5)
y=y1+y2+y3
endfunction
plot(t,f(y1,y2,y3));
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
title("Y1=2u(t)- 3u(t-2.5)+ u(t+5) (continuous time signal for t=-7 to 8)
","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-0.1])
ylabel("signal","fontsize",3,"position",[-1;0.5])
xgrid;
subplot(2,1,2)
n=-5:0.01:5;
y1=ones(n).*(n>0);
y2=ones(n).*(n>3);
y3=3*ones(2*n).*(n<5);
function [y]=f(y1, y2, y3)
y1=ones(n).*(n>0);
y2=ones(n).*(n>3);
y3=3*ones(2*n).*(n<5);
y = y1+y2+y3;
endfunction
plot(n,f(y1,y2,y3));
a=gca();
a.box = "on"
a.x_location = "origin"
a.y_location = "origin"
title("Y2= 3u[2n+5]-u[n-3]+u[n] (discrete time signal for n=-5 to
5)","fontsize",3)
xlabel("time","fontsize",3,"position",[6;-0.1])
ylabel("signal","fontsize",3,"position",[-1;0.5])
xgrid;
Output:

Das könnte Ihnen auch gefallen