Programming with MATLAB
- MATLAB stores data in arrays.
- Use
readmatrix
to read tabular CSV data into a
program.
-
M(row, column)
indices are used to select data
points
-
:
is used to take slices of data
- Use
plot
to visualize data.
- Save MATLAB code in files with a
.m
suffix.
- Use
for
to create a loop that repeats one or more
operations.
- Use
if
and else
to make choices based on
values in your program.
- Break programs up into short, single-purpose functions with
meaningful names.
- Define functions using the
function
keyword.
- Use assertions to catch errors, and to document what behavior is
expected.
- Write tests before code.