Included in this section are some tricks to make MATLAB easier to use.
2.1 Windows stuff
The following shortcuts are for use with the Windows 3.1 version of MATLAB
(version 4.2) that is installed in the computer labs. Newer versions may have
- resizing the command window
To decrease the width of the MATLAB window, move the mouse pointer
to the right border of the window. When the pointer is directly on
the right border it will change to a double arrow. Press the left
mouse clicker and while keeping it held down, move the mouse to the
left. Notice that a highlighted line will appear denoting where the
new right border will be. After you have re-positioned this
vertical highlight about mid-screen, let go or the mouse clicker.
Note that the MATLAB window is narrower, and that it is positioned
on the left-hand side of the screen.
If you click on the upward-pointing arrow in the upper right hand
corner of the MATLAB command window, the window will fill the whole
screen and the button will turn into a double arrow. If you click
on the double arrow, the window should return to its previous size.
- Moving the command window
Aim the mouse pointer at the title bar of the window. Then
press the mouse left-hand clicker and, while keeping it pressed
down, move the mouse, noting that a rectangular highlight moves
along with it. This highlight tells us where the window will move
to. Upon letting go of the mouse clicker, the window will be
- Printing selected text
To print text from the command screen, you need first to select the text (mark a block of text). To do this, using the
mouse, point to the beginning of the text. Press the left mouse
button, and while holding down the button, move (drag) the pointer
to the end of the text to be printed and then release the mouse
button. You will see the selected text highlighted. Point to the
``FILE'' menu in the command window, click the left mouse button,
and point to ``Print selected'' and click again. The selected text
will be sent to the printer. (If this does not work, your computer
may not be configured correctly---ask for help from a lab
technician.) It is important that the desired text be first
selected since, otherwise, the entire history of your MATLAB session
will be printed---wasting a lot of paper!
- to print a graph from the figure window
To send your graph to the printer, click the mouse in the
Figure Window. Then using the mouse, point the arrow to ``FILE" in
the Figure Window and click the left mouse button. Then point the
arrow to ``PRINT" and click again. Your figure will now be printed
on the printer in the Computer Laboratory. WARNING: Make sure you are in the Figure Window -- if you are in the command window, MATLAB will print all your commands, from the start of the sessions.
- If the window you want is hidden, use Ctrl-Esc
(press the Ctrl key and Esc key at the same time). A box with a list
of windows should appear. Click on the window you want, to select it,
then click on ``switch to.''
- You can also use Alt-Tab:
pressing Tab repeatedly with the Alt key held down scrolls through
the names of open windows. Release the Alt key when the window name
you want appears. (These commands work in any Windows application.)
2.2 Command Line Editing
MATLAB has several tricks that will allow you to work faster when you
Using the Arrow keys
Moving to left and right along the line
The usual left and right arrow keys move you forward and backward
along the line as you would expect.
- Exploring your command history
What is really convenient, is the use of the up and down arrows to
scroll through your history. Hitting the up arrow puts the last
command you entered in the command line. Hitting it twice will put
the 2nd to last one. Guess what hitting it 3 times does? Did you
go too far? Then the down arrow goes back down.
- Moving along the line
MATLAB uses some keyboard shortcuts that are common in the
world. In particular they come from the great editor
Move to beginning of line
C-a: That's ``CONTROL - a'' pressed at the same time. The
HOME key does the same.
- Move to end of line
C-e: That's ``CONTROL - e'' pressed at the same time. The
END key does the same
- back one character
C-b: Same as left arrow.
- forward one character
C-f: Same as right arrow.
- ``kill'' all characters to the right
C-k: This will delete all the characters to the right of the
As well, you may find the following to be of use:
The use of a ; can suppress the output:
>> x = [1,2,3,4,5] % no semicolon
ans = 1 2 3 4 5
>> x = [1,2,3,4,5]; % with a ``;'' there is no output
- several commands can be written on one line if separated
by semicolons (
The three lines
>> x = linspace(0,6*pi);
>> y = e.^(-x/10) * sin(x); % damped oscillation example
could be one line
>> x = linspace(0,6*pi);y = e.^(-x/10) * sin(x);plot(x,y);
Figure 1: plot of damped oscillation