I have defined a variable which has two elements y[i,j]
. How can I sum all the components of this variable in Modelica?
Thanks
This is very simple:
sum(y)
See also 10.3.4 Reduction Functions and Operators in the modelica specification.
Note: Your example does not have 2 elements, but i*j. There are 2 dimensions, with i elements in dimension 1 and j elements in dimension 2. See chapter 10.1 Array Declarations for details.