Skip to content

Commit

Permalink
ContinuousSignalExtrema: improved detection of t_min and t_max
Browse files Browse the repository at this point in the history
  • Loading branch information
AHaumer committed Jul 30, 2022
1 parent 8118479 commit 83c156c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions Modelica/Blocks/Math.mo
Expand Up @@ -2557,16 +2557,8 @@ This means that:</p>
//detect local extrema at zero derivative, just before and after a step, and at the end of the simulation
y_min = min({pre(y_min), u, pre(u)});
y_max = max({pre(y_max), u, pre(u)});
if y_min<pre(y_min) then
t_min=time;
t_max=pre(t_max);
elseif y_max>pre(y_max) then
t_min=pre(t_min);
t_max=time;
else
t_min=pre(t_min);
t_max=pre(t_max);
end if;
t_min = if y_min<pre(y_min) then time else pre(t_min);
t_max = if y_max>pre(y_max) then time else pre(t_max);
end when;
annotation (defaultComponentName="signalExtrema",
Documentation(info="<html>
Expand Down
2 changes: 1 addition & 1 deletion Modelica/Blocks/package.mo
Expand Up @@ -1505,7 +1505,7 @@ whereas signalExtrema2 catches the extrema rather good due to the fact that samp
annotation (Placement(transformation(extent={{-80,-40},{-60,-20}})));
Modelica.Blocks.Sources.Sine amplitude(
amplitude=1,
f=0.75,
f=1.75,
offset=0)
annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
Modelica.Blocks.Math.Product product1
Expand Down

0 comments on commit 83c156c

Please sign in to comment.