SUNY Geneseo Department of Mathematics
Friday, April 22
Math 230 02
Spring 2016
Prof. Doug Baldwin
>> % "Equality" relation on {0,1,2}
>> equality = [ 0, 0; 1, 1; 2, 2 ]
equality =
0 0
1 1
2 2
>> % "sumTo" relation on {0,1,2}, (a, b, c) in relation if a = b + c
>> sumTo = [ 0, 0, 0; 1, 0, 1; 1, 1, 0; 2, 0, 2;, 2,2,0; 2,1,1 ]
sumTo =
0 0 0
1 0 1
1 1 0
2 0 2
2 2 0
2 1 1
>> % Save these tables to file "relations.mat"
>> save relations
...
>> % And reload the tables in a later Matlab session
>> load relations
>> equality
equality =
0 0
1 1
2 2
>> % Can't make a matrix with different-length strings in each row:
>> M = [ 'abcd'; 'def' ]
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
>> % But can make a cell array (curly instead of square brackets mean cell array)
>> C = { 'abcd'; 'def' }
C =
'abcd'
'def'
>> % Curly brackets index a cell array
>> C{ 1, 1 }
ans =
abcd