I've been informed what statements we need to know and here are my answers to what they do. Please correct me if I'm mistaken somewhere and please tell me how I learn more advanced statement that I might need e.g. the .*
and .^
for element-wise operation I did not yet learn.
% Mini-Matlab:
% =============
%
% Find out what these statements do!
% Then you can write a Matlab-program.
% "%" starts a Matlab comment
x=[2 3]
The above is like an array, a vector that resides in memory after the statement.
y=[4 5]'
This is a column vector.
A=[x; y']
The semicolon separates the rows of a matrix.
B=sin(A)
This is like a regular mathematical function.
z=x.*y'
This too is just like a function in the classic math / CS.
c=A\y
This is important and solves an equation system but which? How is the original equation stated? Does the above solve Ay=c? Please specify.
a='Hej'
The above is just a variable like in any other computer language.
a(2)='a'
The above sets the second element of the vector a to the string 'a'.
v=3:2:9
The above constructs a vector from 3 to 9 with the step 2.
w=5:3:15
The above constructs a vector from 5 to 15 with the step 3.
t=0:0.05:10;
t becomes a vector between 0 and 10 with increments of 0.05.
f=t.*exp(2*t);
This is just like a regular function definition.
plot(t,f)
This plots the function on the y-axis and the t on the x-axis.
title('Fin kurva');
This just sets the title of the graph.
g=3*t.*sin(t);
This is a more comlex function definition, still easy to understand what it does.
k=cos(t+2)+sin(t.^2);
Another simple function definition.
help XXX % XXX=sin, cos, plot, disp
Accessing the online help system.
if CONDITION
STATEMENTS...
end;
Self-explanatory.
if CONDITION
STATEMENTS...
else
STATEMENTS...
end;
Also self-explanatory.
for VARIABLE = VECTOR
SATSER...
end;
A regular for-loop
while VILLKOR
SATSER...
end;
Easy to understand if you ever programmed.
So I think I understand most of the statement but from this list it appears that the most relevant to study is the equation solver c=A\y that I need to practice how to use.