Saarland University
Lehrstuhl für Automatisierungstechnik

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How to initialize an array of objects?
Roland
post May 6 2009, 10:02 AM
Post #1


Advanced Member
***

Group: Members
Posts: 30
Joined: 2-January 08
Member No.: 5,272



Hello Daniel,

QUOTE(daniel@ka @ Apr 12 2009, 08:42 PM) *

second_order so[10](start ((start y0 = i) for i in 1:10)); // (*)


I guess, a solution for you would be:
CODE
second_order so[10](y0(start = {i for i in 1:10}));


I hope this works for you.

Roland
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
daniel@ka
post Apr 12 2009, 07:42 PM
Post #2


Member
**

Group: Members
Posts: 23
Joined: 3-June 08
Member No.: 11,399



To make the long story short here is my code

package math

model second_order
parameter Real y0 = 1;
parameter Real ydot0 = 1;
Real x;
Real y(start = y0);
Real ydot(start = ydot0);
equation
ydot = der(y);
der(ydot) + der(y) + y = x;
x = if time < 5 then time else 10-time;
end second_order;

model test
second_order so[10];
//second_order so[10](each y0 = 1);
second_order so[10](start ((start y0 = i) for i in 1:10)); // (*)
end test;

end math;

I want to perform kind of a sweep over y0, therefor I need somehow to
pass i value into y0, but I am not sure there is some syntax for this.
Is it possible?

Thx, daniel

ps: Line marked with (*) is not correct, but shows what my intention is.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 16th July 2019 - 11:19 AM