- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Using for loop to assign variable
Page Start Prev 1 Next End
Using for loop to assign variable
Using for loop to assign variable
May-17-19 08:49:35
Hallo everyone,
Code:
Model Foo
MyModel. M1,M2,M3,...,Mn;
Real y1,y2,y3,...,yn;
algortihm
for i in 1:n loop
yi := Mi.output;
end for;
end Foo;
So i want to assign each model output from M[i] to its respective y[i] like the model above and got a translation Error.
is it possible to use for loop to assign variable as i intended above? or it only works for array index?
Cheers
- Arinomo23
- 120 Posts
Re: Using for loop to assign variable
May-17-19 08:51:17
You must use arrays in that case, you can't construct variable names dynamically like that.
- perost
- 114 Posts
Re: Using for loop to assign variable
May-17-19 08:55:34
perost wrote:
You must use arrays in that case, you can't construct variable names dynamically like that.
Okay, thank you very much.
- Arinomo23
- 120 Posts
Page Start Prev 1 Next End
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Using for loop to assign variable
There are 0 guests and 0 other users also viewing this topic