Documente Academic
Documente Profesional
Documente Cultură
Tutorial page:
http://www.cs.utoronto.ca/~yueli/CSC321_UTM_2014.html
Why MATLAB ?
Easy to learn.
I
I
Excellent documentation.
I
Caveats
Starting MATLAB...
To exit:
exit
Operations
I
Matrices
I
A = [1 2 3; 4 5 6] yields
A = [1 2 3
4 3 6]
Matrix algebra
To transpose use
Etc.
Example:
function [y] = timestwo(x)
y = 2*x
% multiply by two...
for-loops
I
while-loops
I
for i = 1 : 0.5 : 5
exp(i)
end
i = 1.1
while i<=2
i = i^2
end
conditionals
I
i = sin(2.1374)
if i < 0.5
i = i^2
end
Plotting
I
For example
x = 1 : 0.5 : 10;
y = sin(x);
plot(x,y)
More plotting
I
E.g.
A = rand(10)
subplot(1,2,1)
imagesc(A)
B = (1:0.1:10)*(1:0.1:10)
subplot(1,2,2)
imagesc(B)
==, <, >, etc. actually return logical matrices (they work
component-wise).
So, if a = [1, 2, 3] you have: