Multidimensional input to a function

9.59K viewsScripting


I am trying to define a simple function using scripting:
* Inputs: a list of elements, for instance item:id[first]..item:id[last]
* Output: any function of the whole elements (sum for instance)

How should I declare the input in the script of the function?

Under Java, I would have declared as input of my method “test” an array of doubles (“input”) containing the values “item:id[first]..item:id[last]” and written:

double test( double[] input ){
int numberItems = input.length;
double result = 0;
for( int i=0 ; i<numberItems ; i++){
result = result + input[i];
return result;

Thank you.



Hi Julien,

Your are doing the most right.

Just write a function like this (a very simple example):

double my_sum(double[] numbers)
double sum = 0

for(double number : numbers)
sum += number
return sum

Then you can use this function formulas like these:
‘Sum Values (items 4 to 8)’ = my_sum(Matrix1::Values:Item4 .. Values:Item8)
Sum all = my_sum(Matrix1::Values)

The clue is that you can define the range (or dimension) of the input in a Quantrix formula.

Take the attached model and play around with it.

Is this what you are looking for?


You are viewing 1 out of 16 answers, click here to view all answers.