ElmoMC SimplIQ Software Manual User Manual

Page 54

Advertising
background image

SimplIQ

Software Manual

4BThe

SimplIQ

User Programming Language

MAN-SIMSW (Ver. 1.4)

5-25

If a function does not return any output by definition, a zero output value will be inserted to
the stack. For example, if the function func is declared with no output arguments, the
expression func( ) + 3 is legal because func returns zero by default.

Example:

float vec[11], RA[100];

Declare the global variables.

float value;

Declare the global variable.

function [float mean, float std]=statistic();

Function

prototype.

[RS[1],RA[2]]=statistic()

Call

the

statistic function. After

execution, RA[1] will be equal to
variable mean and RA[2] will be
equal to variable std.

[value]=statistic()

In this case, after executing the
statistic function, value will be equal
to variable mean.

function [float mean, float std]=statistic();

Declare a function that calculates

mean and standard deviation of the
global vector vec.

int k;

Declare k as automatic variable.

global vec[11];

Redeclare for vec variable (vec is
global variable previously
declared).

mean=0;

for k = 1:10

mean = mean + vec[k];

End

mean = mean/10;

Calculate mean of vec[ ]

if (nargout>1)

Only if standard deviation is
queried . . .

std = 0;

for k = 1:10

std = std + vec[k] * vec [k];

End

st = (1/10) * ssrt. (std – 10 * mean)

End

Return

End of function body

For count of input arguments, the number of input arguments during a function call must be
the same as declared during the function definition.

Advertising