Skip to main content

MATLAB: Generating basic signals



MATLAB program to generate and plot the following continuous-time signals: (a) unit impulse, δ(t), (b) unit step, u(t), (c) unit ramp, r(t), (d) parabolic signal, (e) signum function, (f) sinc function.


MATLAB program:

clc; clear all; close all;
tmin=-10;
tmax=10;
dt=0.1;
t=tmin:dt:tmax;
%*** Impulse function δ(t) *******
delta=1.*(t==0);
subplot(231);plot(t,delta);
xlabel(’t’);ylabel(’delta(t)’);
title(’Unit Impulse function’);

%****Unit step function ***
step=1.*(t>=0);
subplot(232);plot(t,step);
xlabel("t");ylabel("u(t)");
title("Unit Step function");

%*** Unit Ramp function ***
ramp=t.*(t>=0);
subplot(233);plot(t,ramp);
xlabel("t");ylabel("r(t)");
title("Unit Ramp function");

%** Unit parabolic function **
parabolic=(t.^2)/2.*(t>=0);
subplot(234);plot(t,parabolic);
xlabel("t");ylabel("p(t)");
title("Unit Parabolic function");

%** Signum function **
signum=1.*(t>0)+0.*(t==0)+(-1).*(t<0);
subplot(235);plot(t,signum);
xlabel("t");ylabel("sgn(t)");
title("Signum function");

%** Sinc function **
sincf=sinc(t);
subplot(236);plot(t,sincf);
xlabel("t");ylabel("sinc(t)");
title("Sinc function");




Comments