MathScript code requires that you adhere to specific syntax guidelines.
|Code Type||Syntax Guidelines||Examples|
|Array||White spaces or commas separate array elements. Semicolons or line breaks separate rows of an array.||
[1 2 3] or [1, 2, 3] define an array with three columns, each with one value.
[1; 2; 3] defines an array with three rows, each with one value.
|Structure||Structure syntax is <variable>.<field name>.||
point.x = 3.0; point.y = 5.0;Defines a structure with two fields that describe a point within a graph.
point is a scalar structure with the fields x and y. Each field has an assigned numeric value.
|Structure Array||Structure array syntax is <variable(n)>.<field name>.||
point(1).x = 3.0; point(1).y = 4.0; point(2).x = 3.5; point(2).y = 5.0;
Defines two structure elements that describe points.
|Variable Name||A variable name cannot begin with an underscore, a white space, or a digit.||a
Separated decimals: 2.1
Complex numbers: 2+3i or 2+3j
|Comment||Comment lines begin with a % character.||% This is a comment.|
Command separation: a=abs(b), c=sin(d)
a=abs(b) ... + abs(c)
Short-circuit evaluation: The command if 0 == 0 || abs(a) == 1 does not execute abs(a) because the first part of the expression already is TRUE. Similarly, the command if 0 ~= 0 && abs(a) == 1 does not execute abs(a) because the first part of the expression already is FALSE.