Linear interpolation in two dimensions of a table. The grid points and function values are stored in a matrix "table[i,j]", where:
Example:
| | | | | 1.0 | 2.0 | 3.0 | // u2 ----*-------*-------*-------* 1.0 | 1.0 | 3.0 | 5.0 | ----*-------*-------*-------* 2.0 | 2.0 | 4.0 | 6.0 | ----*-------*-------*-------* // u1 is defined as table = [0.0, 1.0, 2.0, 3.0; 1.0, 1.0, 3.0, 5.0; 2.0, 2.0, 4.0, 6.0] If, e.g. the input u is [1.0;1.0], the output y is 1.0, e.g. the input u is [2.0;1.5], the output y is 3.0.
The table matrix can be defined in the following ways:
tableName is "NoName" or has only blanks, fileName is "NoName" or has only blanks.
save tables.mat tab1 tab2 tab3 -V4when the three tables tab1, tab2, tab3 should be used from the model.
Table definition methods (1) and (3) do not allocate dynamic memory, and do not access files, whereas method (2) does. Therefore (1) and (3) are suited for hardware-in-the-loop simulation (e.g. with dSpace hardware). When the constant "NO_FILE" is defined, all parts of the source code of method (2) are removed by the C-preprocessor, such that no dynamic memory allocation and no access to files takes place.
If tables are read from an ASCII-file, the file need to have the following structure ("-----" is not part of the file content):
----------------------------------------------------- #1 double tab1(5,2) # comment line 0 0 1 1 2 4 3 9 4 16 double tab2(5,2) # another comment line 0 0 2 2 4 8 6 18 8 32 -----------------------------------------------------
Note, that the first two characters in the file need to be "#1". Afterwards, the corresponding matrix has to be declared with type, name and actual dimensions. Finally, in successive rows of the file, the elements of the matrix have to be given. Several matrices may be defined one after another.