ModelicaAdditions.Tables.Examples.allTables
The usage of the tables is demonstrated. Simulate for 7 s. In the range 0..1 and 3..5, the table outputs of table0, table1, table2 need to be identical. At the other time instants, different extrapolation formula are used.
| Name | Default | Description |
|---|---|---|
| tab[:, :] | [2, 0.5, 1; 3, 2, 3; 4, 1, 2] | |
| offset | 10 | |
| startTime | 1 | |
| columns[:] | {2,3} | |
| tab2[:, :] | [-1, -1; 0, 0; 0, 1; 1, 2] | |
| tab3[:, :] | [0, 0; 0, 1; 1, 2] |
encapsulated model allTables "Show usage of all tables"
import Modelica.Icons;
import Modelica.Blocks.Sources;
import ModelicaAdditions.Tables;
extends Icons.Example;
parameter Real tab[:, :]=[2, 0.5, 1; 3, 2, 3; 4, 1, 2];
parameter Real offset=10;
parameter Real startTime=1;
parameter Integer columns[:]={2,3};
parameter Real tab2[:, :]=[-1, -1; 0, 0; 0, 1; 1, 2];
parameter Real tab3[:, :]=[0, 0; 0, 1; 1, 2];
Tables.CombiTableTime2 table0(
table=tab,
columns=columns,
offset={offset},
extrapolation={0},
startTime={startTime});
Tables.CombiTableTime2 table1(
table=tab,
columns=columns,
offset={offset},
extrapolation={1},
startTime={startTime});
Tables.CombiTableTime2 table2(
table=tab,
columns=columns,
offset={offset},
extrapolation={2},
startTime={startTime});
Tables.CombiTableTime combiTableTime(table=tab2);
Tables.CombiTable1D CombiTable1D1(table=[0, 0; 1, 1; 2, 4; 3, 9; 4, 16; 5
, 25; 6, 36]);
Tables.CombiTable1Ds CombiTable1Ds1(table=[0, 0, 0; 1, 1, 1; 2, 4, 8; 3, 9
, 27; 4, 16, 64; 5, 25, 125; 6, 36, 216], icol=2:3);
Sources.Ramp Ramp1(height={10}, duration={10});
Tables.CombiTable2D CombiTable2D1;
Sources.Ramp Ramp2(height={10}, duration={10});
Sources.Ramp Ramp3(height={10}, duration={10});
Tables.CombiTableTime2 combiTableTime2(table=tab2);
equation
connect(Ramp1.outPort, CombiTable1D1.inPort);
connect(Ramp1.outPort, CombiTable1Ds1.inPort);
connect(Ramp2.outPort, CombiTable2D1.inPort1);
connect(Ramp3.outPort, CombiTable2D1.inPort2);
end allTables;