Code Snippets Modelica

Short texts Modelica 🧑‍💻 Code snippets Modelica ✍️ Reading lists Modelica 👀

Model linear Interpolation

model linearInterpolation “Building Block for linar Interpolation” Modelica.Blocks.Interfaces.RealInput u annotation (Placement(transformation(extent={{-128,-20},{-88,20}}))); Modelica.Blocks.Interfaces.RealOutput y annotation (Placement(transformation(extent={{94,-10},{114,10}}))); Modelica.Blocks.Sources.SampleTrigger trigger(period=timeInterval) annotation (Placement(transformation(extent={{-60,-40},{-40,-20}}))); parameter Modelica.SIunits.Time timeInterval(start=25) = 25; Real lastValue; Real nextValue; protected Modelica.SIunits.Time t0, t1; initial equation lastValue = u; nextValue = u; t0 = time; t1 = time + timeInterval; equation when trigger.y then lastValue = pre(nextValue); […]