You are on page 1of 5

Signals and Systems

Name: Shaunak Mulye

Roll No: SE246

Exp 1: Generate and Plot following signals in time domain and also
sketch its amplitude and phase spectrum.

i)Impulse
Code:
clc;
rng("default");
sys = rss(5);
h = impulseplot(sys);
d = fdesign.lowpass(.4,.5,1,80);
sosFilt = design(d,"ellip",Systemobject=true)
impz(sosFilt);

Graphs:

ii)Unit Step
Code:
clc;
n= input ('Enter the value of n=');
t=0:1:n-1;
y=ones(1,n);
figure;
stem(t,y);
title('Unit step: Discrete Time');
xlabel('Time');
ylabel('Amplitude');
grid on;
figure;
plot(t,y);
title('Unit step: Continious Time');
xlabel('Time');
ylabel('Amplitude');
grid on;

Graphs:

iii) Exponential
Code:
clc;
n= input ('Enter the value of n=');
t=-2:0.5:n;
y=exp(t);
figure;
stem(t,y);
title('Exponential Signal: Discrete Time');
xlabel('Time');
ylabel('Amplitude');
grid on;
figure;
plot(t,y);
title('Exponential Signal: Continious Time');
xlabel('Time');
ylabel('Amplitude');
grid on;
Graphs:

iv) Unit Ramp


Code:
clc;
n=input('Enter the number upto which you want to plot: ')
t=0:1:n;
stem(t,t);
figure;
title('Ramp: Discrete Time');
xlabel('Time');
ylabel('Amplitude');
grid on;
hold on;
figure;
plot(t,t);
title('Ramp: Continuous Time');
xlabel('Time');
ylabel('Amplitude');
grid on;

Graphs:
v) Sinc
Code:
t = -10:0.01:10;
x_cont = sinc(t);
n = -20:20;
x_disc = sinc(n);
subplot(2,1,1);
plot(t, x_cont, 'b', 'LineWidth', 2);
xlabel('Time (t)');
ylabel('Amplitude');
title('Continuous Time sinc Function');
grid on;
subplot(2,1,2);
stem(n, x_disc, 'r', 'filled');
xlabel('Sample (n)');
t = -10:0.01:10;
x_cont = sinc(t);
n = -20:20;
x_disc = sinc(n);
subplot(2,1,1);
plot(t, x_cont, 'b', 'LineWidth', 2);
xlabel('Time (t)');
ylabel('Amplitude');
title('Continuous Time sinc Function');
grid on;
subplot(2,1,2);
stem(n, x_disc, 'r', 'filled');
xlabel('Sample (n)');
ylabel('Amplitude');
title('Discrete Time sinc Function');
grid on;

Graph:
vi) Rectangular
Code:
clc;
n= input ('Enter the value of n=');
t=-5:0.01:n;
y=rectpuls(t,n);
figure;
plot(t,y);
title('Rectangular: Continious Time');
xlabel('Time');
grid on;
ylabel('Amplitude');

Graphs:

You might also like