Itw 1
Itw 1
Workshop
LECTURE 1
Syntax Basics
Continue Long Statements on Multiple
Lines
This example shows how to continue a statement to the next line using ellipsis (...).
Use the name=value syntax to help identify name-value arguments for functions and to clearly
helpFile = which('help');
[helpPath,name,ext] = fileparts(helpFile);
To ignore function outputs in any position in the argument list, use the tilde operator. For example,
[~,name,ext] = fileparts(helpFile);
You can ignore any number of function outputs using the tilde operator. Separate consecutive tildes
with a comma. For example, this code ignores the first two output arguments.
[~,~,ext] = fileparts(helpFile);
Variable Names
Examples of valid names:
x6
lastValue
n_factorial
6x
end
n!
Case and Space Sensitivity
MATLAB code is sensitive to casing, and insensitive to blank spaces except when defining
arrays.
For example, MATLAB interprets the following statements the same way.
y = sin (3 * pi) / 2
y=sin(3*pi)/2
For example, the statement [1 sin (pi) 3] produces a much different result than [1 sin(pi) 3] does.
enclosed in single quotation marks) and does not assign outputs to user defined variables.
A = 123;
disp(A)
123