The command line in MATLAB can be easily edited. The cursor can be
positioned with the left/right arrows and the Backspace key used to
delete the character to the left of the cursor. Other editing features
are also available. See help cedit.
A convenient feature is use of the up/down arrows to scroll through the stack of previous commands. One can, therefore, recall a previous command line, edit it and execute the revised command line. For small routines, this is much more convenient than using an M-file which requires moving between MATLAB and the editor. For example, flopcounts for computing the inverse of matrices of various sizes could be compared by repeatedly recalling, editing and executing a = rand(8); flops(0); inv(a); flops If one wanted to compare plots of the functions y = sinmx and y = sinnx on the interval [0,2*pi] for various m and n, one might do the same for the command line: m=2; n=3; x=0:.01:2*pi; y=sin(m*x); z=cos(n*x); plot(x,y,x,z) |