clear; clc; close ; A = [1,2;3,4]; B = [1,-1;1,-1];

advertisement
clear; clc; close all;
A
B
C
D
=
=
=
=
[1,2;3,4];
[1,-1;1,-1];
[1,0,-1;-1,1,0];
A*B;
E = A*C;
%F = C*A
%2x2 matrix
%2x2 matrix
%2x3 matrix
%Matrix Multiplication: # of columns of first matrix
%must be the # of rows of second matrix
%(2x2)*(2x3): Works
%(2x3)*(2x2): Doesn't work
a = [1:5];
%b = a^2
c = a.^2;
d = 2*[1:5];
e = 2.*[1:5];
%Creates a vector of values
%element by element calc: requires a '.' see pg72-74
%Creates a vector by evaluating each entry in x
%Note scalar calculations don't require the '.'
%But they will still work if you put the '.'
f = [1,2,3];
g = [1,0,-1];
dot(f,g);
cross(f,g);
%Look on page 77 for useful functions on vectors
%Dot product of vectors, f and g
%Cross product of vectors, f and g
%As always for more hints look at sample problems
Published with MATLAB® R2014a
1
Download