Matlab Programs for Elementary signals
Unit Step Function: -
n= -10:10;
u= [zeroes (1,10) ones (1,11)];
stem(n,u);
axis (-12 12 -1 2);
title (‘Unit step’);
xlabel(‘Time’);
ylabel(‘Amplitude’);
Output:
Rectangular Pulse: -
fs=500;
T=0.2;
t=-0.5:1/fs:0.5;
x=rectpuls (t, T);
plot (t, x,'K');
axis ([-0.5 0.5 0 2]);
title ('Rectangular pulse');
xlabel('Time');
ylabel('Amplitude');
Output: -
Unit Ramp Function
n=input (‘enter value up to which you want to plot’);
t=0:1: n;
stem (t, t);
plot (t, t);
title (‘Ramp function’);
xlabel(‘Time’);
ylabel(‘Amplitude’);
Output: - 5
Triangular Function: -
t=1:10;
x= [1 0 1 0 1 0 1 0 1 0];
plot (t, x);
title ('Triangular pulse');
xlabel('Time');
ylabel('Amplitude');
Output: -
Unit Impulse Function: -
n= [-3:4];
y= [0 0 0 1 0 0 0 0];
stem (n, y);
title ('Unit Impulse function');
xlabel('Time');
ylabel('Amplitude');
Output: -