Lab-2-MTE-2210 Ryan
Lab-2-MTE-2210 Ryan
Lab-2-MTE-2210 Ryan
Sessional Report
Submitted by
Solution:
Matlab Code:
For step signal,
t=0:0.01:10;
x=heaviside(t-2);
plot(t,x);
xlabel('t');
ylabel('u(t-to)')
axis([-1 5 0 1.5]);
For ramp signal,
t=-20:20;
x=heaviside(t);
r=1+t.*x;
plot(t+2,r)
xlabel('t');
ylabel('x(t)')
axis([0 20 0 20]);
Output:
For step signal,
Solution:
Matlab Code:
n=0:1:8;
x=[0 0 1 2 3 4 5 4 3];
subplot(2,1,1)
stem(n,x)
title('x(n) signal')
xlabel('n')
ylabel('x(n)')
subplot(2,1,2)
stem(-n,x)
title('y(n)=x(-n) signal')
xlabel('n')
ylabel('y(n)')
Output:
Output:
D. Write a MATLAB program to compute the cross correlation
between signals and Sequences. x=cos(2*pi*10*t), y=cos(2*pi*15*t)
by increasing the amplitude of the signal by 3 times.
Solution:
Matlab Code:
t=0:0.001:1;
x=3*cos(2*pi*10*t);
y=3*cos(2*pi*15*t);
a=xcorr(x,y);
subplot(3,1,1);
plot(t,x,'g');
xlabel('time');
ylabel('amplitude');
title('1st signal');
subplot(3,1,2);
plot(t,y,'r');
xlabel('time');
ylabel('amplitude');
title('2nd signal');
subplot(3,1,3);
plot(a,'r');
xlabel('time');
ylabel('amplitude');
title('cross correlation signal');
Output:
Output:
This system is time-invariant, since the output signals of the system are just time-
shifted versions of each other's, when the input are time-shifted versions of each
other.
Solution:
Given,
input force f(t) = 1
The differential equations of the system is,
my"(t) + by'(t) + ky(t) = f(t)
=> my"(t) + by'(t) + ky(t) = 1 .......................(1) [As f(t) = 1]
Eq.(1) will be used to determine the system response y(t) in MATLAB.
Matlab Code:
m = 10;
b = 0.5;
k = 1;
syms t y(t)
y1(t) = diff(y,t);
ode = m*diff(y1,t) + b*y1(t) + k*y(t) == 1;
c1 = y(0) == 0;
c2 = y1(0) == 0;
y(t) = dsolve(ode,c1,c2);
t = 0:0.1:200;
digits(5);
y1 = double(vpa(y(t)));
plot(t,y1,'b');grid on;
xlabel('time ->');
ylabel('amplitude ->');
title('System response y(t)');
y_max = max(y1);
disp("Peak Amplitude = "+y_max);
Output:
So, the peak amplitude of the output is 1.7794 which is about to 1.8 [Showed]
Output:
For z=3,
For z=6,
For z=12,