block PosPeak "Positive peak during one period"
extends Modelica.Blocks.Interfaces.SISO;
parameter Modelica.SIunits.Frequency f=1 "Basic signal frequency";
protected
Real x;
equation
x=max(u,x);
when sample(0, 1/f) then
y=x;
reinit(x,u); // not standard compliant!
end when;
end PosPeak;
Reported by AHaumer on 7 May 2008 11:01 UTC
The Modelica specification doesn't allow to reinit a continuous variable which isn't a state;
but how should I get the peak value of a signal with respect to predefined periods:
Migrated-From: https://trac.modelica.org/Modelica/ticket/74