Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
%or a:b = <strong>from</strong> a to b<br />
%1:5 = [1 2 3 4 5]<br />
%vect(1:2) = [3 4]<br />
1:5<br />
vect(1:2)<br />
%move by a step other than 1 by using 2 colons<br />
10:2:20 %<strong>from</strong> 10 to 20 by 2s<br />
%end means the last element of a row or column<br />
%so vect(2:end) = [4 5];<br />
vect(2:end)<br />
%an apostrophe ' transposes a vector or matrix<br />
%vect' = [3<br />
% 4<br />
% 5]<br />
vect'<br />
%concatenation<br />
x = [1 2 3]<br />
y = [4 5 6]<br />
[x y] %horizontal<br />
[x; y] %vertical<br />
%basic operators, +, -, *, /<br />
%on scalars these work as expected<br />
3 + 4<br />
2 * 2<br />
% ^ is the power operator<br />
2^3<br />
%on vectors and matrices they use linear algebra<br />
x = [1 2 3]<br />
y = [4 5 6]<br />
x*y' %dot product<br />
x'*y %cross product<br />
%if you want to mutliply and divide, element by element use dot functions, .* ./ .^<br />
x.*y %note the dot<br />
%logical operators<br />
% >,