There are several windows; you'll work mostly with the Command Window by typing commands at the prompt and reading the results. The other windows tell you about your file, variables and previous commands. If you want you can close all the windows except the Command Window. You can restore the windows by selecting them under the View menu.
MATLAB has several built-in help commands:
You can use the up and down arrows to go through the command you previously typed.
x = 1 x = 'hi' x = 2
x = pi format long e disp(x) format short disp(x) format rat x format short x
( 1 2 3 ) ( 4 5 6 ) ( 7 8 9 )in any of the following ways:
A =[1, 2, 3; 4, 5, 6; 7, 8, 9] B=[1 2 3; 4 5 6; 7 8 9] C = [ 1 2 3 4 5 6 7 8 9 ]
You can also build matrices by putting a value in each place. Like
D(1,1) = 1 D(1,2) = 2 D(1,3) = 3 D(2,1) = 4 D(2,2) = 5 D(2,3) = 6 D(3,1) = 7 D(3,2) = 8 D(3,3) = 9
NOTE: MATLAB will automatically make your matrix big enough to hold the elements you specify. It will set unspecified entries to 0
If you tried this stuff you probably noticed that MATLAB displayed the results after every command you gave it. This is great when we are learning to use MATLAB, but it gets pretty annoying later. If you end a command with a semi-colon, then the results will not be displayed. Try typing: E(3,4) = 1; (don't forget the semi-colon)
What do you think the result is? Type E or disp(E) to see the result. Are you surprised?
If the elements are defined by a formula, you can write a little program,
for example:
for i = 1:3 for j = 1:3 F(i,j) = i+j; end end disp(F)
Some matrix types are built into MATLAB. Try these:
M = magic(5) Z = zeros(4,3) I = eye(5) W = ones(3,2) R = rand(3)Each of these takes either 1 or 2 numbers for the size of the matrix.
Another way is to open a text file either through MATLAB (it would be a M-file) or through your favorite word processor and then copy the good stuff into the text file.