- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » how to connet array of two different...
how to connet array of two different type
how to connet array of two different type
Hello, i am a little bit confused by the for loop:
I try to connect two different component array using for loop, but it dosent work.
model Test
parameter Integer N = 2;
Modelica.Blocks.Sources.Constant const[N](each k = 273.15 + 100);
ThermoCycle.Components.HeatFlow.Sources.Source_T_cell source_T_cell[N]
equation
// it dose not work
for i in 1: N-1 loop
connect(const[N].y, source_T_cell[N].Temperature);
end for;
/* but the following works
connet(const.y, source_T_cell.Temperature);
*/
end Test;
can some one tell me, how to connet two differnt array of components in Modelica.
best regards
Re: how to connet array of two different type
I guess that should be:
Code:
for i in 1: N-1 loop
connect(const[i].y, source_T_cell[i].Temperature); // note that you have i instead of N
end for;
You could also do it via he slice operator and without the for loop:
Code:
connect(const[1:N-1].y, source_T_cell[1:N-1].Temperature);
- adrpo
- 885 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » how to connet array of two different...