Plotting Unit Impulse, Unit Step, Unit Ramp and Exponential Function in MATLAB

t=-2:1:2;
y=[zeros(1,2), ones(1,1), zeros(1,2)];
subplot(2,2,1);
stem(t,y);
ylabel('d(n)');
xlabel('unit impulse');

n=input('Enter n values');
t=0:1:n-1;
y1=ones(1,n);
subplot(2,2,2);
stem(t,y1);
ylabel('Amplitude');
xlabel('unit step');

n=input('Enter n values');
t=0:1:n-1;
subplot(2,2,3);
stem(t,t);
ylabel('Amplitude');
xlabel('unit ramp');

n=input('Enter length of exponential seq');
t=0:1:n-1;
a=input('Enter a value');
y2=exp(a*t);
subplot(2,2,4);
stem(t,y2);
xlabel('Exponential fun');
ylabel('Amplitude');

Output

Enter n values5
Enter n values4
Enter length of exponential seq5
Enter a value2
Output

2 thoughts on “Plotting Unit Impulse, Unit Step, Unit Ramp and Exponential Function in MATLAB”

  1. The presented way of plotting impulse, step and ramp is completely incorrect. Watch for generating impulse.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.