Familiarize with MATLAB environment.
Learn variables, vectors, matrices, and scripts.
Generate simple mathematical functions.
clc;
clear;
t = 0:0.01:5;
x = sin(2*pi*t);
plot(t,x);
grid on;
Generate and plot:
Unit Step
Ramp
Exponential
Sinusoidal
t = -5:0.01:5;
u = t>=0;
r = t.*u;
x = exp(-t).*u;
s = sin(2*pi*t);
subplot(2,2,1);
plot(t,u); title('Unit Step');
subplot(2,2,2);
plot(t,r); title('Ramp');
subplot(2,2,3);
plot(t,x); title('Exponential');
subplot(2,2,4);
plot(t,s); title('Sine Wave');
Study:
Amplitude Scaling
Time Shifting
Time Reversal
t=-5:0.01:5;
x=sin(t);
subplot(2,2,1);
plot(t,x);
title('Original');
subplot(2,2,2);
plot(t,2*x); title('Amplitude Scaling');
subplot(2,2,3);
plot(t-2,x); title('Time Shift');
subplot(2,2,4);
plot(-t,x); title('Time Reversal');
To perform the convolution of two continuous-time signals using MATLAB and analyze the output response.
clc;
clear;
close all;
dt = 0.01;
t = -2:dt:3;
% Input signal
x = (t>=0 & t<=1);
% Impulse response
h = (t>=0 & t<=1);
% Continuous-time convolution
y = conv(x,h)*dt;
% Time axis for convolution
ty = (2*t(1)):dt:(2*t(end));
% Plot results
subplot(3,1,1)
plot(t,x,'LineWidth',2)
grid on
title('Input Signal x(t)')
xlabel('Time (s)')
ylabel('Amplitude')
subplot(3,1,2)
plot(t,h,'LineWidth',2)
grid on
title('Impulse Response h(t)')
xlabel('Time (s)')
ylabel('Amplitude')
subplot(3,1,3)
plot(ty,y,'LineWidth',2)
grid on
title('Convolution Output y(t)=x(t)*h(t)')
xlabel('Time (s)')
ylabel('Amplitude')
--------------------------------------------------------------------------
clc;
clear;
close all;
dt = 0.01;
t = -1:dt:5;
u = (t>=0);
x = exp(-t).*u;
h = u;
y = conv(x,h)*dt;
ty = (2*t(1)):dt:(2*t(end));
subplot(3,1,1)
plot(t,x,'LineWidth',2)
grid on
title('x(t)=e^{-t}u(t)')
subplot(3,1,2)
plot(t,h,'LineWidth',2)
grid on
title('h(t)=u(t)')
subplot(3,1,3)
plot(ty,y,'LineWidth',2)
grid on
title('Continuous-Time Convolution')
xlabel('Time')