Denis Schluppeck
2022-11-21
Everything should work
=
function
…for
loop (repeating things)true(), false()
and if
statement (doing things only in certain conditions)cell
arrays (using more than numbers)+ - * /
etc.add, subtract, multiply, divide numbers like this:
.*
versus *
(/
versus ./
).*
and ./
(more on the extra “dot” later)( )
to make order of operations explicit:3/2
value of pi (\(\pi\)). What do you think this could be called in Matlab?
two times pi (\(\pi\))
2 to the power of 8
4 to the power of 3
64 to the power of one third
to store the results (and work on them), you can put data in a variable
>> a = 10 % stores the number 10 in a variable called "a"
>> b = 2+2 % stores the result of 2+2 in "b"
To illustrate, let’s make a special example matrix (it’s special: all rows and columns add to the same value)
Use parentheses after variable name. To e.g. get the 2nd row, 4th column:
Remember: you can use the :
to get everything along a dimension.
Find where the array fulfills certain rules. (true
, false
)
Pretend your array is one big long list (go down rows first, then columns, …).
For M
(which was 5 by 5), that means 25 entries.
doc('function')
to find out much more