Unit step using MATLAB

In this section we will be learned how to implement unit step in MATLAB.


MATLAB code:


%unit impulse


n=-10:20


us=[zeros(1,10) 1 zeros(1,20)];


subplot(3,1,1);


stem(n,us);


title('unit impulse')


%delayed unit impulse


usd=[zeros(1,15) 1 zeros(1,15)];


subplot(3,1,2);


stem(n,usd);


title('delayed unit impulse')


%advanced unit impulse


usa=[zeros(1,3) 1 zeros(1,27)];


subplot(3,1,3);


stem(n,usa);


title('advanced unit impulse')


axis([-10 20 0 1.2]); %defining axis

OUTPUT:

1 comment:

Ichthus18 said...

Your introduction mentions unit "STEP", but the code is only for unit "IMPULSE".?

Post a Comment