Language
Basic syntax
Assignments, comments, strings, blocks, and output behavior.
01
Statements
A newline or semicolon separates statements. A trailing semicolon suppresses implicit output; disp always writes through the host.
% Comments begin with percent
answer = 6 * 7;
message = "hello";
disp(answer);02
Values
- Real and complex numbers use double-precision components.
- true and false are distinct booleans; all-boolean literals form logical arrays.
- Single- and double-quoted strings escape a matching quote by doubling it: 'it''s' or "say ""hello""". Strings cannot span lines.
- After a complete operand, apostrophe is conjugate transpose, not a string opener. Use A.' for nonconjugating transpose.
- Dense real, logical, and complex arrays use [columns; rows] syntax.
- [value, index] = max(A) assigns multiple outputs; ~ discards an output position. %% comments mark executable Studio sections.
03
Blocks
Conditionals, loops, selection, exception handlers, and functions close with end. Headers end with a newline or semicolon.