|
|
Availability
MATLAB is available onFirst steps
Running MATLAB using M-Files
You can work with MATLAB interactively as above, but I recommend to get into the habit of working from a file right away. This makes it much easier to trace back your steps, correct errors and produce output that can be verified. M-files contain a sequence of commands just like those you type in the command window.function y = square(x)
after which can follow any MATLAB commands. At the end of the function, y should have some value (eg y=x^2), which is then returned. You can call your function by doing z = square(t); (similarly, any MATLAB function). Several input variables are possible, but only one output variable - make the output a vector if it contains several numbers. Typing help square displays the headline comment(s) you wrote.Sample M-Files
You can download these, execute them and modify them.