Ticket #4545: MWE_2017_10_06.mo

File MWE_2017_10_06.mo, 852 bytes (added by Francesco Casella, 7 years ago)
Line 
1package MWE_2017_10_06
2 model Test_vector
3 Real x[2](each start = 0, each fixed = true);
4 discrete Real u[2](each start = 0, each fixed = true);
5 Real y[2];
6 equation
7 for i in 1:2 loop
8 der(x[i]) = u[i];
9 y[i] = 0.5*x[i];
10 end for;
11 algorithm
12 when sample(0,1) then
13 for i in 1:2 loop
14 u[i] := 1 - y[i];
15 end for;
16 end when;
17
18 annotation(experiment(StopTime = 10));
19 end Test_vector;
20
21 model Test_scalar
22 Real x(start = 0, fixed = true);
23 discrete Real u(start = 0, fixed = true);
24 Real y;
25 equation
26 der(x) = u;
27 y = 0.5 * x;
28 algorithm
29 when sample(0, 1) then
30 u := 1 - y;
31 end when;
32 annotation(
33 experiment(StopTime = 10));
34 end Test_scalar;
35
36 annotation(
37 Diagram(coordinateSystem(extent = {{-200, -100}, {200, 100}})));
38end MWE_2017_10_06;