EE341.01: MATLAB SESSION FOR PLOTTING COMMON WAVEFORMS

This example shows how MATLAB commands can be typed at the MATLAB prompt to plot unit ramp and unit step functions. Note that the diary file 'e1_diary' was used to store the commands typed as well as the MATLAB responses.

Commands Typed and MATLAB Responses:
>> diary e1_diary
>> clear
>> t = -1:0.01:1;
>> r = t.*(t >= 0);
>> u = ones(size(t)).*(t >= 0);
>> subplot(2,1,1);
>> plot(t,r);
>> grid;
>> xlabel('t ');
>> ylabel('r(t)');
>> title('Unit Ramp');
>> subplot(2,1,2);
>> plot(t,u);
>> grid;
>> xlabel('t ');
>> ylabel('u(t)');
>> title('Unit Step');
>> diary off
Resulting e1_diary Diary File:
clear
t = -1:0.01:1;
r = t.*(t >= 0);
u = ones(size(t)).*(t >= 0);
subplot(2,1,1);
plot(t,r);
grid;
xlabel('t ');
ylabel('r(t)');
title('Unit Ramp');
subplot(2,1,2);
plot(t,u);
grid;
xlabel('t ');
ylabel('u(t)');
title('Unit Step');
diary off

MATLAB Plot Generated:

The plot was printed by typing 'print' at the MATLAB prompt when the plot was displayed in the graphics window.