SimulationX extends Modelica by the last
-operator which returns the last accepted value of the argument. At event-time points it returns the value at which the integration stopped before the event iteration.
The last
-operator can be used to calculate the maximum of the current x
value and the last maximum. See the following working example.
model test "test.ism"
extends SimModel;
Real x=2*sin(2*pi*time)+sin(20*pi*time)+(if time < 0.5 then 0 else 3) "some input signal with jump";
Real y=if noEvent( time > time.start ) then max(x,last(y)) else x "Calculate the maximum with the help of the last-operator";
Real z(start=0,fixed=true)=-der(z)+y "Just any dymanics.";
end test;
The input signal x
and the corresponding output signal y
are depicted in the following Figure.
