BoAcharai › Lessons › MATLAB

Step-by-step lesson · MATLAB

How to write a function in MATLAB

5 steps · Written for Mac. On Windows, use Ctrl for Command and Alt for Option.

  1. Create a new file named area.m
  2. Type function A = area(r) on the first line
  3. Type A = pi * r^2; on the next line
  4. Type end and save the file
  5. In the Command Window, type area(2)

More in MATLAB

All MATLAB lessons