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('tResulting e1_diary Diary File:'); >> ylabel('r(t)'); >> title('Unit Ramp'); >> subplot(2,1,2); >> plot(t,u); >> grid; >> xlabel('t '); >> ylabel('u(t)'); >> title('Unit Step'); >> diary off
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('tMATLAB Plot Generated:'); ylabel('r(t)'); title('Unit Ramp'); subplot(2,1,2); plot(t,u); grid; xlabel('t '); ylabel('u(t)'); title('Unit Step'); diary off
The plot was printed by typing 'print' at the MATLAB prompt when the plot was displayed in the graphics window.