SNS Lab 2
SNS Lab 2
MATLAB Code:
x = -5:0.1:5 ;
% Define parameters:
m = 0;
s = 1;
xlabel('x');
ylabel('y');
title('plot y(x)');
function y = f(x, m, s)
end
Output:
plot y(x)
0.4
0.35
0.3
0.25
0.2
y
0.15
0.1
0.05
0
-5 -4 -3 -2 -1 0 1 2 3 4 5
x
Task 02:
MATLAB Code:
clear;clc;close all;
A).
t = -pi:0.01:pi ; % Define parameter
plot(t , a);
xlabel('time');
ylabel('amplitude');
B) .
syms t
u = @(t)double(t>0)
b = u(tr+1)+u(tr-2)+u(tr+4);
figure;
plot(tr,b);
xlabel('time');
ylabel('amplitude');
Output:
Plot the continuous time signal with heaviside
3
2.5
amplitude 2
1.5
-3 -2 -1 0 1 2 3 4
time
FIGURE 2
2.5
amplitude
1.5
-3 -2 -1 0 1 2 3 4
time
FIGURE 3
Task 03:
MATLAB Code:
clc;clear;close all;
% Define parameters
subplot(2,3,1);
title('Cosine Wave');
xlabel('Time');
ylabel('Amplitude');
subplot(2,3,2);
title('Sin Wave');
xlabel('Time');
ylabel('Amplitude');
subplot(2,3,3);
xlabel('Time');
ylabel('Amplitude');
subplot(2,3,4);
xlabel('Time');
ylabel('Amplitude');
subplot(2,3,5);
d= plot(sin(pi/2*t),'b_', 'LineWidth', 1)
title('Sin Wave');
xlabel('Time');
ylabel('Amplitude');
subplot(2,3,6);
title('Cosine Wave');
xlabel('Time');
ylabel('Amplitude');
Output:
0.5 0.5 1
Amplitude
Amplitude
Amplitude
0 0 0
-0.5 -0.5 -1
-1 -1 -2
0 200 400 600 0 200 400 600 0 200 400 600
Time Time Time
Combined Sine and Cosine Waves Sin Wave Cosine Wave
2 1 1
1 0.5 0.5
Amplitude
Amplitude
Amplitude
0 0 0
-1 -0.5 -0.5
-2 -1 -1
0 200 400 600 0 200 400 600 0 200 400 600
Time Time Time
MATLAB Code:
clc;clear;close all;
a = diff(y,t)
b = int(y,t,-inf,inf)
Output:
Task 05:
MATLAB Code:
clear;clc;close all;
syms t
a = int(dirac(t),t)
Output:
Lab Analysis:
In this lab, I learn about the discrete-time equivalent of the unit impulse function is known as
the unit pulse function or the kronecker delta function. I learned about the the derivative of
the unit step function is known as the unit impulse function, or the dirac delta function . I
learned about how to take derivative and integration in matlab.