>> A = [ 11 12 13
21 22 23 ]
Commas or blank spaces separate row entries inside the matrix-builder
brackets "[]", while
semicolons or carriage returns separate the column entries. So as shown
earlier,
x = [1 2 3] is a row vector, while x = [1; 2; 3] is a column vector.
A = [V,x]is an nx(n+1) array, and
B = [x' ; V]is an (n+1)xn array. It is real common to build up a vector or array step-by-step inside a loop using matrix builder brackets.
1.23132E+01 8.54579E+00 1.21672E+01 . . . 8.53653E+00 8.56410E+00then I use my trusty text editor to insert lines before and after the text in the output file:
A = [
1.23132E+01
8.54579E+00
1.21672E+01
.
.
.
8.53653E+00
8.56410E+00
];
subplot(2,1,1);
plot((1:length(A)),A, '*')
title('Times for Small Memory Job')
ylabel('Seconds')
xlabel('Run Number')
subplot(2,1,2);
hist(A,40)
title('Times for Small Memory Job')
xlabel('Seconds')
ylabel('Number of Runs')
This creates a plot of those times, and a histogram:
save filename var1 var2 ... varnsaves the variables listed in a binary file called "filename.mat".
load filenameor
load filename x1 x2 ... xnwith the same kinda restrictions and uses as the save command.
As an important reminder ...
Beware: By default, the result of all assignment operations are printed.
Appending a semicolon (;) to end of an assignment suppresses this printing.
The command sequence
>> A = zeros(100,100); >> for j = 1:100 >> for i = 1:100 >> A(i,j) = 1.0/(i+j-1) >> end >> endwill print out approximately 50 million doubles. This is because when a single component of an array is assigned to and the semicolon is omitted, the entire array is printed - not just the changed component.
A better mechanism is to use the save and load commands. By default they will save/load a binary file containing all of the variables in your current workspace - sort of a snapshot of the session. You can also save just specified variables, save to an ASCII format file, etc. A good use for save is when you hit a bug while working, and cannot get around it. Save your workspace along with a note of what you were trying to do, so that it can be easily reloaded and demonstrated to me (or to Mathworks, if it is their bug!)