TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING IOE PURWANCHAL CAMPUS DHARAN
Lab Report of Signal Analysis
Submitted By: Submitted To:
Name: Shishir Kumar Acharya Er. Dhartiraj Shah
Rollno:PUR076BEL042 Department of Electrical Engineering
Department: Electrical Purwanchal Campus Dharan
Lab1.Generation of Continuous time sinusoidal signal
Code
t=-pi:0.01:pi;
x=sin(t);
plot(t,x,'k');
title('sinusoidal signal');
xlabel('time');
ylabel('amplitude');
Output:
Lab2. Generation Of Continuous Time Cosine Signal
Code
t=-pi:0.01:pi;
x=cos(t);
plot(t,x,'k');
title('cosine signal');
xlabel('time');
ylabel('amplitude');
Output:
Lab 3.Generation of Continuous time unit step signal
Code:
% Define signal parameters
t = -5:0.001:5; % time vector, with 0.001 seconds time step
% Generate unit step signal
x = heaviside(t);
% Plot the signal
plot(t, x);
xlabel('Time (s)');
ylabel('Amplitude');
title('Continuous Unit Step Signal');
Output:
Lab 4.Generation of continuous time ramp signal
Code:
% Define signal parameters
t = -5:0.001:5; % time vector, with 0.001 seconds time step
a = 2; % slope of the ramp
b = 1; % y-intercept of the ramp
% Generate ramp signal
x = a*t + b;
% Plot the signal
plot(t, x);
xlabel('Time (s)');
ylabel('Amplitude');
title('Continuous Ramp Signal');
Output:
Lab 5.Generation of Continuous time sinc Function
Code:
% Define signal parameters
f = 5; % frequency in Hz
t = -1:0.001:1; % time vector, with 0.001 seconds time step
% Generate sinc signal
x = sinc(2*f*t);
% Plot the signal
plot(t, x);
xlabel('Time (s)');
ylabel('Amplitude');
title('Continuous Sinc Signal');
Output:
Lab 6.Generation Of Continuous Time Expotential Signal
Code:
% Define signal parameters
t = -5:0.001:5; % time vector, with 0.001 seconds time step
a = 1; % initial amplitude
r = 0.5; % decay rate
% Generate exponential signal
x = a*exp(-r*t);
% Plot the signal
plot(t, x);
xlabel('Time (s)');
ylabel('Amplitude');
title('Continuous Exponential Signal');
Output:
Lab 7. Convolution Of x(t)=𝑒 −𝑎𝑡 u(t) and h(t)=u(t).
Code:
a = 2;
t = 0:0.001:10;
% Define the input signal
x = exp(-a*t).*heaviside(t);
% Define the impulse response
h = heaviside(t);
% Perform the convolution
y = conv(x, h, 'same')*0.001;
% Plot the input, impulse response, and output signals
plot(t, x, 'r', t, h, 'b', t, y, 'g');
xlabel('Time (s)');
ylabel('Amplitude');
legend('x(t)', 'h(t)', 'y(t)');
title('Convolution of x(t) and h(t)');
Output:
Lab 8.Convolution of x[n]={1,3,2,1,1} and h[n]={1,2,-1,1}.
Code:
%convolution of x[n]={1,3,2,1,1} and h[n]={1,2,-1,1}
x=[1,3,2,1,1];
h=[1,2,-1,1];
y=conv(x,h);
subplot(311);
stem(x,'k');
title('x[n]');
grid on;
subplot(312);
stem(h,'k');
title('h[n]');
grid on;
subplot(313);
stem(y,'k');
title('y[n][convolved output]');
grid on;
Lab 9.Generation of discrete time unit impulse signal
Code:
hold on;
for(n=-10:10)
if (n==0)
stem(n,1,'k');
else
stem(n,0,'k');
end;
end;
xlabel('n');
ylabel('delta[n]');
title('discrete time impulse signal');
Output:
Lab 10:Generation of Discrete time unit step signal
Code:
hold on;
for(n=-10:10)
if (n<0)
stem(n,0,'k');
else
stem(n,1,'k');
end;
end;
xlabel('time');
ylabel('amplitude');
title('unit step sequence');
Output:
Lab 11:Generation of discrete time sinusoidal signal
%Discrete time sinusoidal signal
n=-pi:1:pi;
x=sin(n);
stem(n,x,'k');
xlabel('n');
ylabel('x[n]');
title('Discrete time sinusoidal signal');
Output:
Lab12.Generation of Discrete time Cosine Signal
Code:
%Discrete time Cosine signal
n=-pi:1:pi;
x=cos(n);
stem(n,x,'k');
xlabel('n');
ylabel('x[n]');
title('Discrete time Cosine signal');
Output