2D Graphics: Stair Plot

The stair plot is another way to represent the discrete data. Useful to represent digitally sampled data.  Also useful to explain numerical techniques for integration

MATLAB Code
% 2D Graphics - Stair Plot
%  discrete representation of data
% Dr. P.Venkataraman
format compact
set(gcf,'Toolbar','none','Name','Stair Plot', ...
'NumberTitle','off','Position',[10,350,500,360]);
%********************Change problem below
a = 0; b =5;  np = 50;  % data control

% developing variables
x = a:(b-a)/(np-1):b;    % x - values
y1 = 3*exp(-0.5*x);
y2 = sin(3*x);
y =y1.*y2;
textstr(1)={'y = y_1 * y_2'};
textstr(2)={'y_1 = 3 e^{-x} , y_2 = sin(3x)'};

%******************************

stairs(x,y)
hold on

plot(x,y,'k--')
plot(x,y1,'r:')
plot(x,y2,'g:')
% formatting
xlabel('\bfx','FontSize',10,'FontName','Arial', ...
'Color','b','VerticalAlignment','middle')
ylabel('\bfy','FontSize',10,'FontName','Arial', ...
'Color','r')

title('\bf\itStair Plot- Discrete plot of function','Color','k')
text(2.5,2.2,textstr)
hold off