Documentation

Basic Operators

a + b

sum

  • a -> scalar, string or matrix
  • b -> scalar, string or matrix
a - b

substraction

  • a -> scalar or matrix
  • b -> scalar or matrix
a * b

multiplication

  • a -> scalar or matrix
  • b -> scalar or matrix
a / b

division

  • a -> scalar
  • b -> scalar
a % b

modulus, returns the remainder of the division a/b (a an b can be float numbers).

  • a -> scalar
  • b -> scalar
a ^ b

power a to b

  • a -> scalar
  • b -> scalar

Comparison Operators

a && b

and compare

  • a -> scalar
  • b -> scalar
a || b

or compare

  • a -> scalar
  • b -> scalar
!a

not a, if a is equal to 0, then the expression returns 1, otherwise it returns 0.

  • a -> scalar
a >= b

equal or greater than

  • a -> scalar
  • b -> scalar
a > b

greater than

  • a -> scalar
  • b -> scalar
a <= b 

equal or less than

  • a -> scalar
  • b -> scalar
a < b

less than

  • a -> scalar
  • b -> scalar
a == b

equal to

  • a -> scalar,string or matrix
  • b -> scalar,string or matrix

 

a != b

not equal

  • a -> scalar,string or matrix
  • b -> scalar,string or matrix

Bitwise Operators

~a

Performs a bitwise NOT (negation) on an expression.

  • a -> scalar
y = and(a,b)
y= a & b

bitwise and

  • a -> integer value
  • b -> integer value

returns
y -> bitwise and, if a or b are not integer, the decimals are truncated to do the operation.

y = or(a,b)
y= a | b

bitwise or

  • a -> integer value
  • b -> integer value
    returns
    y -> bitwise or, if a or b are not integer, the decimals are truncated to do the operation.
y = xor(a,b)
y= a ^^ b

bitwise xor

  • a -> integer value
  • b -> integer value

returns
y -> bitwise xor, if a or b are not integer, the decimals are truncated to do the operation.

Trigonometric and hyperbolic functions

y = acos(x)

Arc cosine

  • x -> value in range [-1 +1]

returns

y -> arc cosine in radians, if x is out of range then the function return (nan)

y = acosh(x)

Arc hyperbolic cosine

  • x -> value in range [1 ∞]

returns

y -> arc hyperbolic cosine, if x is out of range then the function return (nan)

y = asin(x)

Arc sine

  • x -> value in range [-1 +1]

returns

y -> arc sine in radians, if x is out of range then the function return (nan)

y = asinh(x)

Arc hyperbolic sine

  • x -> value in range [1 ∞]

returns

y -> arc hyperbolic sine in radians, if x is out of range then the function return (nan)

y = atan(x)

Arc tangent

  • x -> value

returns

y -> arc tangent in radians in range [-π/2 π/2]

y = atan2(a,b)

arc tangent with two parameters, calculates the arc tangent of a/b using the signs of both parameters to set the correct quadrant.

  • a -> value
  • b -> value

returns

y -> arc tangent in radians

y = atanh(x)

Arc hyperbolic tangent

  • x -> value in range [-1 +1]

returns

y -> arc hyperbolic tangent in radians, if x is out of range then the function return (nan)

y = cos(x)

cosine

  • x -> value in radians

returns

y -> cosine, range [-1 1]

y = cosh(x)

hyperbolic cosine

  • x -> value in radians

returns

y -> hyperbolic cosine

y = sin(x)

sine

  • x -> value in radians

returns

y -> sine, range [-1 1]

y = sinh(x)

hyperbolic sine

  • x -> value in radians

returns

y -> hyperbolic sine

y = tan(x)

tangent

  • x -> value in radians

returns

y -> tangent

y = tanh(x)

hyperbolic tangent

  • x -> value in radians

returns

y -> hyperbolic tangent

Logarithmic, power and exponential functions

y = hypot(a,b)

Hypotenuse

  • a -> real value
  • b -> real value

returns
y -> √(a2+b2)

y = log(x)

natural logarithm

  • x -> value

returns

y -> natural logarithm of x, if x is invalid value for logarithm, returns (nan)

y = log10(x)

logarithm base 10

  • x -> value

returns

y -> logarithm base 10 of x, if x is invalid value for logarithm, returns, (nan)

y = log2(x)

logarithm base 2

  • x -> value

returns

y -> logarithm base 2 of x, if x is invalid value for logarithm, returns, (nan)

y = heronf(a,b,c)

Heron’s formula, calculates the area of a triangle with sides length a, b, and c

  • a, b, c -> value

and return

y -> triangle´s area

r = loglog(...)

plot data in log scale in axis x and y. (More info in Graph section)

  • (…) -> values (vectors)

returns

r -> 0

r = semilogx(...)

plot data in log scale in x axis. (More info in Graph section)

  • (…) -> values (vectors)

returns

r -> 0

r = semilogy(...)

plot data in log scale in y axis. (More info in Graph section)

  • (…) -> values (vectors)

returns

r -> 0

y = √(x)
y = sqrt(x)

square root

  • x -> value

returns

y -> square root of x

Rounding functions

y = ceil(x)

Round up number

  • x -> value

returns

y -> round to nearest integer greater than x, example:

>>> ceil([-5.1 -4.9 2.3 6.8+5.1i])

ans = [-5 -4 3 7+6i]

 

y = floor(x)

Round down number

  • x -> value

returns

y -> round to nearest integer lower than x, example:

>>> floor([-5.1 -4.9 2.3 6.8+5.1i])

ans = [-6 -5 2 6+5i]

y = round(x)

Round nearest number

  • x -> value

returns

y -> round to nearest integer, example:

>>> round([-5.1 -4.9 2.3 6.8+5.1i])

ans = [-5 -5 2 7+5i]

y = trunc(x)

Truncate the decimals of x

  • x -> value

returns

y -> truncate decimals, example:

>>> trunc([-5.1 -4.9 2.3 6.8+5.1i])

ans = [-5 -4 2 6+5i]

Graphing

graphnew()

opens a new window to plot.

return 0

graphset(x)

select the current graph window (with window title)

  • x -> string, select the current graph window

Note: the window title can be changed with the command

graphsetprop("WindowName”,winName)

return 0

graphsetprop(property,...)
  • property -> string, property to be changed
  • … -> depends of property.

Property values accepted:

  • WindowName set the window title or name
  • addData on set the current plot (not the window) to append the next data to the graph
  • addData off set the current plot (not the window) to replace the data of graph (this is the mode by default)
  • clear clear the plot data.
  • axis Set the axis limits in plot example:

graphsetprop("axis",[-2 2 -4 4])

loglog(x,..)

plot data with logarithm scale in horizontal and vertical axis.

check plot function about the additional arguments.

subplot(rows,cols,index)

divides the graph window into rows and columns plots, and the index selects the plot in a subplot of rows and columns, the index 1 is the upper right plot of the window.

plot(x)
plot(x,y)
plot(x,y,opt)
plot(x1,y1,opt,...)

Plot the data, if the function is “plot(x)” and x is complex, then the plot will be the same as “plot(real(x),imag(x))”.
The plot can the append data like “plot(x1,y1,x2,y2,y3,opt3)” with or without options.
options values accepted:

  • “r” red color
  • “g” green color
  • “b” blue color
  • “k” black color
  • “y” yellow color
  • “m” magenta color
  • “k” black color
  • “c” cyan color
  • “o” circle bullet data
  • “s” square bullet data
  • “–” dash lines
  • ” ” (space) no line
  • “|” vertical lines
semilogx(x,..)

plot the data in a graph with logarithm scale in horizontal and linear scale in vertical axis. Check plot function about the additional arguments.

semilogy(x,..)

plot the data in a graph with linear scale in horizontal axis and logarithm scale in vertical axis.
check plot function about the additional arguments.

Image

Om = imgaffinetr(Im,tr)

Apply an affine transform to image pixel position

  • Im -> Image value
  • tr -> 2×3 matrix with the affine values.

returns

Om -> an image with the the transform, the pixel values outside the image a refilled with 0.
the new pixel values are calculated as:

[x' ; y'] = tr * [x ; y ; 1]

where

tr=[rotXX rotXY translationX; rotYX rotYY translationY]

Om = imgAYCbCrToARGB(Im)
Om = imgAYCbCrToARGB(Im,mode)

Convert an image in AYCbCr(4:4:4) format to ARGB.

  • Im -> Image value
  • mode -> String value the only supported value is “601-4”

returns

Om -> return a ARG image,if mode is not defined, convert the image using the standard ITU-Recommendation BT.709-2, if mode is set to “601-4” then use the ITU-Recommendation BT.601-4.

Om = imgchannel(Im)
Om = imgchannel(Im,channel)

Split the channels of image

  • Im -> Image value
  • channel -> Integer, channel number (default -1)

returns

Om -> if channel is -1, returns all channels in a vector; or if channel is set, returns the matrix with the scalar values of the channel selected.

Om = imgclip(Im,clip)

Clip values og the image

  • Im -> Image value
  • clip -> vector 1×2, where clip(0) is the low value and clip(1) is the high value

returns

Om -> the image within range clip(0) to clip(1). do the following operation.

if(Ipx>clip(1)){

Opx = clip(1)

}else if(Ipx<clip(0)){

Opx = clip(0)

}else{

Opx = Ipx

}

Om = imgclose(Im,kernel)

image close morphing operation

  • Im -> Image value
  • kernel -> matrix of integers with odd size example:3×1 or 5×7 etc.

returns

Om -> the image with the applied operation.(equivalent to dilate and then erode)

Om = imgconv(Im,kernel,bias,d)

image convolution

  • Im -> image ARGB or G
  • kernel -> must be integer, kernel, the size must be odd
  • bias -> must be integer, value added to each element in a convolution result(default 0)
  • d -> must be integer, divisor of kernel (default, width*height of kernel)
  • Om -> result image of convolution

Note: Alpha channel is not modified

examples:

b=imgconv(a,[1 1 1; 1 1 1; 1 1 1])

b=imgconv(a,[1 1 1; 1 1 1; 1 1 1],128)

b=imgconv(a,[255 255 255; 255 255 255; 255 255 255],0,2295)

Om = imgdeconvRLucy(Im,k1,d1,it,k2,d2)

Deconvolve the image

  • Im -> image ARGB or G
  • k1 -> must be integer, kernel 1, the size must be odd
  • d1 -> must be integer, divisor of kernel 1 (default, sizex*sizey of kernel 1)
  • it -> must be integer, num. of iterations (default 10)
  • k2 -> must be integer, kernel 2, the size must be odd, useful only if kernel1 is asymmetrical (default, this is ignored)
  • d2 -> must be integer, divisor of kernel 2(default, sizex*sizey of kernel 2, only if kernel 2 is set, otherwise is ignored)
  • Om -> result image

Note: Alpha channel is not modified

More info in vImageRichardsonLucyDeConvolve_ARGB8888

examples:

b=imgdeconvRLucy(a,[1 1 1; 1 1 1; 1 1 1])

b=imgdeconvRLucy(a,[1 1 1; 1 1 1; 1 1 1],20)

b=imgdeconvRLucy(a,[1 1 1; 1 1 1; 1 1 1],9,5)

b=imgdeconvRLucy(a,[1 1 0; 1 1 1; 1 1 0],9,5,[0 1 0; 1 1 1; 1 1 0],9)

Om = imgdilate(Im,kernel)

image dilate morphing operation

  • Im -> Image value
  • kernel -> matrix of integers with odd size example:3×1 or 5×7 etc.

returns

Om -> the image with the applied operation.

Om = imgerode(Im,kernel)

image erode morphing operation

  • Im -> Image value
  • kernel -> matrix of integers with odd size example:3×1 or 5×7 etc.

returns

Om -> the image with the applied operation.

y = imghist(Im)

image histogram

  • Im -> Image value

returns

Om -> vectors with size 256 with the image histogram.

Om = imgload(file)

load a image from file

  • file -> String value

returns

Om -> loaded image, if the “file” has “iCloud:” prefix when the image is load from the iCloud.

Om = imgmatrixmult(Im,M)
Om = imgmatrixmult(Im,M,div)
Om = imgmatrixmult(Im,M,div,prebias)
Om = imgmatrixmult(Im,M,div,prebias,postbias)

Multiply each pixel by matrix M

  • Im -> ARGB image
  • M -> matrix 4×4 integers values
  • div -> integer value, divisor of multiplication (default 3).
  • prebias -> integer value, offset applied before the matrix multiplication.
  • postbias -> integer value, offset applied after the matrix multiplication.

returns

Om -> image

Om = imgmax(Im, [height width])

image max morphing operation

  • Im -> Image value
  • height -> integer value, of kernel to apply the operation.
  • width -> integer value, of kernel to apply the operation.

returns

Om -> the image with the applied operation.

Om = imgmin(Im, [height width])

image min morphing operation

  • Im -> Image value
  • height -> integer value, of kernel to apply the operation.
  • width -> integer value, of kernel to apply the operation.

returns

Om -> the image with the applied operation.

Om = imgopen(Im,kernel)

image open morphing operation

  • Im -> Image value
  • kernel -> matrix of integers with odd size example:3×1 or 5×7 etc.

returns

Om -> the image with the applied operation.(equivalent to erode and then dilate)

Om = imgrotate(Im,angle)

image rotation

  • Im -> Image value
  • angle -> scalar value.

returns

Om -> the rotated image.

y = imgsave(file)

save a image from file

  • file -> String value

returns

y -> 0, if the “file” has “iCloud:” prefix when the image is saved in iCloud.

Om = imgscale(Im,scale)

image scale

  • Im -> Image value
  • scale -> scalar value.

returns

Om -> the scaled image.

Om = imgsetvalue(Im,channel,value)

image with value to selected channel

  • Im -> Image value
  • channel -> integer value
  • value -> integer value or matrix of size of Im

returns

Om -> image with value to selected channel.

Example:

to fill an image with alpha 255

>>> Om = imgsetvalue(Im,0,255)

to replace the Red channel with other 1 channel image

>>> Om = imgsetvalue(Im,1,Sm)

y = imgshow(Im)

displays image

  • Im -> Image value

returns

y -> 0.

Om = imgthr(Im,level)

Image treshold

  • Im -> Image value
  • level -> integer value.

returns

Om -> the image within range 0 to 255. do the following operation.

if(Ipx>level){

Opx = 255

}else{

Opx = 0

}

Om = imgToAYCbCr(Im)
Om = imgToAYCbCr(Im,mode)

Convert in image inARGB to AYCbCr(4:4:4) format.

  • Im -> Image value
  • mode -> String value the only supported value is “601-4”

returns

Om -> return a AYCbCr image, if mode is not defined, convert the image using the standard ITU-Recommendation BT.709-2, if mode is set to “601-4” then use the ITU-Recommendation BT.601-4.

a = matjoin(a)
y = matjoin(a,b)

join two matrix elements (useful with images)

  • a -> matrix value
  • b -> matrix value (same size of a)

returns

y -> a new matrix with vectors containing the elements of each matrix, example:

a = [7 9 8 0 ;
2 0 9 4 ;
9 1 1 0] b = [0 6 1 9 ;
9 10 6 5 ;
7 3 10 2]

>>> y = matjoin(a,b)
y = [[7 0] [9 6] [8 1] [0 9] ;
[2 9] [0 10] [9 6] [4 5] ;
[9 7] [1 3] [1 10] [0 2]]

y = matsplit(a)

split in matrices the sub elements of a (useful with images)

  • a -> matrix value with sub elements(must have the same number of sub-elements in the matrix), example a = [[5 6 7] [8 5 5] [4 3 5]]

returns

y -> a nested matrix a containing an array of matrices containing the elements, example with two sub-elements:

y = [[7 0] [9 6] [8 1] [0 9] ;
[2 9] [0 10] [9 6] [4 5] ;
[9 7] [1 3] [1 10] [0 2]] >>> [a b] = matsplit(y);
>>> a
a = [7 9 8 0 ;
2 0 9 4 ;
9 1 1 0] >>> b
b = [0 6 1 9 ;
9 10 6 5 ;
7 3 10 2]

Matrices

y = conv(a,b)

convolution of vector a and b

  • a -> vector
  • b -> vector

returns

y -> convolution of a and b; example:

>>> u = [3 3 0 3 14];

>>> v = [15 5 5 13 14];

>>> conv(u,v)

ans = [45 60 30 99 306 127 109 224 196]

y = cross(a,b)

cross product between a and vectors

  • a -> vector of size 3 (any orientation)
  • b -> vector of size 3 (any orientation)

returns

y -> cross product

y = det(x)

determinant of square matrix x

  • x -> square matrix

returns

y -> determinant of x

y = dot(a,b)

dot product

  • a -> value must be 1xM or Mx1 size
  • b -> value must be 1xM or Mx1 size

returns

y -> dot product

1 = eye()
y = eye(a)
y = eye(a,b)

Identity matrix

  • a -> integer value
  • b -> integer value (default b=a)

returns

y -> identity matrix of size a,b; example:

>>> eye()

ans = 1

>>> eye(3)

ans = [1 0 0 ;

0 1 0 ;

0 0 1]

>>> eye(3,4)

ans = [1 0 0 0 ;

0 1 0 0 ;

0 0 1 0]

y = filteri(num,den,sig)
y = filteri(num,den,sig,yi)
y = filteri(num,den,sig,yi,xi)

filter signal with the transfer function.

  • num -> vector, numerator
  • den -> vector, denominator
  • sig -> vector, signal input
  • yi -> vector, output initial conditions (yi=0)
  • xi -> vector, input initial conditions (default xi=0)

returns

y -> filter signal with the transfer function with numerator num and denominator den.

example:

for step input with a transfer function of:

the filteri function will be
>>> y=filteri([0 0.5 -0.11 -.3],[1 -1.9 1.6 -0.6 0.05],zeros(1,30)+1);

and if the initial conditions are y(-1)=1.5,y(-2)=2; in x(-1)=0 x(-2)=1.2
>>> y=filteri([0 0.5 -0.11 -.3],[1 -1.9 1.6 -0.6 0.05],zeros(1,30)+1,[1.5 2],[0 1.2]);

y = fft(x)

Fast fourier transform

x -> vector size of power 2, and some other sizes.

returns

y -> return the vector of the Discrete Fourier Transform or return 0, if the size of x is not implemented to apply the algorithm.

y = ifft(x)

Inverse Fast fourier transform

  • x -> vector size of power 2, and some other sizes.

returns

y -> return the vector of the Inverse Discrete Fourier Transform or return 0, if the size of x is not implemented to apply the algorithm.

y = inv(x)

inverse matrix

  • x -> square matrix

returns

y -> inverse matrix

a = matjoin(a)
y = matjoin(a,b)

join two matrix elements (useful with images)

  • a -> matrix value
  • b -> matrix value (same size of a)

returns

y -> a new matrix with vectors containing the elements of each matrix, example:

a = [7 9 8 0 ;
2 0 9 4 ;
9 1 1 0] b = [0 6 1 9 ;
9 10 6 5 ;
7 3 10 2]

>>> y = matjoin(a,b)
y = [[7 0] [9 6] [8 1] [0 9] ;
[2 9] [0 10] [9 6] [4 5] ;
[9 7] [1 3] [1 10] [0 2]]

y = matsplit(a)

split in matrices the sub elements of a (useful with images)

  • a -> matrix value with sub elements(must have the same number of sub-elements in the matrix), example a = [[5 6 7] [8 5 5] [4 3 5]]

returns

y -> a nested matrix a containing an array of matrices containing the elements, example with two sub-elements:

y = [[7 0] [9 6] [8 1] [0 9] ;
[2 9] [0 10] [9 6] [4 5] ;
[9 7] [1 3] [1 10] [0 2]]

>>> [a b] = matsplit(y);
>>> a
a = [7 9 8 0 ;
2 0 9 4 ;
9 1 1 0]

>>> b
b = [0 6 1 9 ;
9 10 6 5 ;
7 3 10 2]

y = max(x)

Maximum value of x

  • x -> value, vector or matrix

returns

y -> the maximum value of x and the index, if x is a matrix get the maximum of each column and its row position; example.

a = [14 4 15 2 ;

10 10 0 14 ;
0 1 11 3 ;
6 1 2 3]

>>> max(a)
ans = [[14 10 15 14] [0 1 0 1]]

y = mean(x)

Average value of x

  • x -> value, vector or matrix

returns

y -> the average value of x, if x is a matrix get the average of each column and returns as a vector; example.

a = [14 4 15 2 ;

10 10 0 14 ;
0 1 11 3 ;
6 1 2 3] >>> mean(a)
ans = [7.5 4 7 5.5]

y = min(x)

Minimum value of x

  • x -> value, vector or matrix

returns

y -> the minimum value of x and the index, if x is a matrix get the minimum of each column and its row position; example.

a = [14 4 15 2 ;

10 10 0 14 ;
0 1 11 3 ;
6 1 2 3] >>> min(a)
ans = [[0 1 0 2] [2 2 1 0]]

y = size(x)

Size of x

  • x -> value, scalar, vector or matrix

returns

y -> a 1,2 vector containing in index 0 the number of rows and index 1 the number of columns.

y = sort(a)
y = sort(a,b)

Sort a

  • a -> value, vector or matrix
  • b ->string, must be “ascend” or “descend”

returns

y -> the sorted matrix, sorting each column, if a is a vector, sort the vector in any orientation.

y = sum(x)

Summation of x

  • x -> value, vector or matrix

returns

y -> if x is a matrix, return a vector with the summation of each column, if a is a vector, return a scalar.

y = sumsq(x)

Summation of square x

  • x -> value, vector or matrix

returns

y -> returns the following operation sum(x.*x)

y = resize(x,[height width])

resize matrix x

  • a -> matrix value
  • height -> integer value
  • width -> integer value

returns

y -> a matrix with the dimension of height and width, if the matrix is bigger, then is filled with 0

y = xcorr(a)
y = xcorr(a,b)

cross correlation

  • a -> vector value

returns

y -> returns cross correlation of a and b, if b is not defined, then return the autocorrelation of a.

y = zeros(a)

y = zeros(a,b)

matrix of zeros

  • a -> integer value
  • b -> integer value (default b=a)

returns

y -> matrix of zeros of size a,b

Complex numbers

y = abs(x)

magnitude

  • x -> value

returns

y -> √(xr2+xi2)

y = arg(x)

angle between real and imaginary component

  • x -> value

returns

y -> atan2(xi,xr), angle in radians

y = cj(x)

conjugate for each element of x

  • x -> value

returns

y -> conjugate

y = imag(x)

imaginary part of x

  • x -> value

returns

y -> imaginary part as real number

y = rect(m,ø)

convert the polar real numbers to a rectangular complex number

  • m -> real value, magnitude
  • ø -> real value, angle in radians

returns

y -> imaginary number with rectangular coordinate.

y = unitV(x)

return a scalar or quaternion of magnitude 1

  • x-> scalar value or quaternion

returns

y -> a scalar or quaternion with magnitude 1

Quaternions

U * V operator

Complex base algebra operator or CB product.

Its a experimental algebra that can be an operation complementary to the quaternion multiplication(quat product). This has a different structure to set the x,y and z.

U ^ V operator

Quaternion operator.

It is quaternion multiplication.

U˚ operator

Vector conjugate, it is need to conjugate each element of vector is done with the function cj(U).

cinv(x)

CB inverse, is equal to the vector divided by the square magnitude. It is same quaternion inverse except for the signs.

qinv(x)

Quaternion inverse, is equal to the vector conjugate divided by the square magnitude. For the complex version check the Complex Quaternion section.

det(x)

Complex quaternion “determinant” is defined as .

cdet

QuaternionMode(a)

Set the complex quaternion multiplication mode. Parameter “a” is 0 to set the complex multiplication in default mode and parameter “a” to 1 to set the complex multiplication to Dual mode.(explained in Complex Quaternion section)

y = unitV(x)

return a scalar or quaternion of magnitude 1

  • x-> scalar value or quaternion

returns

y -> a scalar or quaternion with magnitude 1

Math-c | Scripting Language

Math-c can interpret multiple lines of instructions ending with the characters “…”

Example:

>>> x = [1 4 5; …
>>> 6 7 8; …
>>> 4 8 7]

x = [1 4 5;
6 7 8;
4 8 7 ]

break;

stop the current loop.

clc()

clear the text of command window.

return

y -> 0.

clear()
clear(a..N)

erase the environment variables in the current scope

  • a..N -> string, variable number of parameters

returns

y -> 0. if the parameter is empty erase the environment variables, if a..N are defined, erase of the variable name selected.
If parameter “a” is equal to “reset functions”, erase all the custom functions defined by the user and set default build in functions

continue;

continue the current loop.

do
dowhile

do-while loop

example to loop 10 times:

i = 0;
do
//code here
i+=1
dowhile(i<10) ///also can be written as dowhile i<10

error(x)

display the error string x and exits the script

  • x -> string

returns

y -> 0

exit()

exits the script

returns

y -> 0

for

for loop

example to loop 10 times:

for i=1:10 ///also can be written as for(i=1:10)
//code here
end

function
return

keyword to define a function, must return a value or matrix.

example:

function myfunctionName(num1,num2)

return num1 + num2;

end

then to call this function in code:

value = myfunctionName(3,2)

if

Execute the code if the condition is diferent of zero or true.

Example.

if x==1

a=2;

else

a=5;

end

import

import the functions defined in other file.

Note: the file is taken from the selected directory path is set in Math-c > Preferences, if is not exist, is taken from iCloud.

only imports the functions and doesn’t validate them until are executed.

Does not run any code from the imported file, only add the functions.

Other limitation from the imported files is that can not be debugged.

Example:

#import signalfuncs.mc

y = input(x)

stop program and ask for input to user displaying the string x.

  • x -> String

returns

y -> the value entered by user

y = isArray(x)

return if is an array.

  • x -> value

returns

y -> 0 if false and 1 if true

y = isinf(x)

return if value x is infinite.

  • x -> value

returns

y -> 0 if false and 1 if true

y = isInteger(x)

return if value x is integer.

  • x -> value

returns

y -> 0 if false and 1 if true

y = isnan(x)

return if value x is nan (undefined number).

  • x -> value

returns

y -> 0 if false and 1 if true

y = isString(x)

return if value x is string.

  • x -> value

returns

y -> 0 if false and 1 if true

print(x)

displays string x to command window.

  • x -> String

returns

y -> 0

y = str(format,x)

format the number to format .

  • format -> string
  • x -> scalar value

returns

y -> formated string

more information can be found in the printf function of C programming

  • f ~ for float
  • g ~ short notation
  • x ~ hexadecimal notation
  • u ~ unsigned integer
  • o ~ octal notation
  • %l#x ~ hexadecimal prefix
  • %.(number) number of decimals to display

example:
>>> x=7+3i
>>> str(“%lf”,x) //only real float
ans = 7.000000

>>> str(“%.2lf im-> %lg”,x) //2 decimals float and short representation
ans = 7.00 im-> 3

>>> str(“%ld im-> %l#x”,x) //integer and hexadecimal format
ans = 7 im-> 0x3

>>> str(“%+ld im-> %lo”,x) //integer with sign and octal
ans = +7 im-> 0x3

 

y = strlen(x)

Get the string length.

  • x -> string

returns

y -> integer

while

while loop

example to loop 10 times:

i=0

while i<10

//code here
i+=1
end