EXPERIMENT - 4


AIM

To plot Continuous and Discrete Heaviside Unit Step Function in MATLAB.

THEORY

The Heaviside step function, or the unit step function, usually denoted by H , is a discontinuous function whose value is zero for negative argument and one for positive argument.

H(x)={1if x00if x<0 H(x) = \begin{cases} 1 & \text{if } x \geq 0 \\ 0 & \text{if } x < 0 \end{cases}

MATLAB COMMANDS USED

* plot(x,y,color,properties)
* heaviside(t);
* stem(x);

MATLAB CODE


t=-1:0.01:1;
y=heaviside(t);
subplot(2,1,1);
%The Code is for continuous unit step
plot(t,y,'b');
xlabel('time in seconds');
ylabel('y(t)');
title('Plot of  continuous heaviside unit 
step function from -1 to 1');

%Discrete unit step
n = -20:1:20;
y= heaviside(.05*n);
subplot(2,1,2);
stem(n,y,'b','filled');
xlabel('n i.e. Sample number');
ylabel('y(n)');
title('Plot of  discrete heaviside unit 
step function from -1 to 1');

print('Unit Step','-dpng')

RESULT

The Continuous and Discrete versions of Unit step or Heavside Function has been plotted.