Univariate constant, linear or cubic Hermite spline interpolation in one dimension of a table. Via parameter columns it can be defined how many columns of the table are interpolated. If, e.g., columns={2,4}, it is assumed that 2 output signals are present and that the first output interpolates via column 2 and the second output interpolates via column 4 of the table matrix.
The grid points and function values are stored in a matrix "table[i,j]", where the first column "table[:,1]" contains the grid points and the other columns contain the data to be interpolated. Example:
table = [0, 0; 1, 1; 2, 4; 4, 16] If, e.g., the input u = 1.0, the output y = 1.0, e.g., the input u = 1.5, the output y = 2.5, e.g., the input u = 2.0, the output y = 4.0, e.g., the input u =-1.0, the output y = -1.0 (i.e., extrapolation).
smoothness = 1: Linear interpolation = 2: Akima interpolation: Smooth interpolation by cubic Hermite splines such that der(y) is continuous, also if extrapolated. = 3: Constant segments = 4: Fritsch-Butland interpolation: Smooth interpolation by cubic Hermite splines such that y preserves the monotonicity and der(y) is continuous, also if extrapolated. = 5: Steffen interpolation: Smooth interpolation by cubic Hermite splines such that y preserves the monotonicity and der(y) is continuous, also if extrapolated. = 6: Modified Akima interpolation: Smooth interpolation by cubic Hermite splines such that der(y) is continuous, also if extrapolated. Additionally, overshoots and edge cases of the original Akima interpolation method are avoided. = 7: Natural cubic spline interpolation, such that der(y) and der2(y) are continuous.
extrapolation = 1: Hold the first or last value of the table, if outside of the table scope. = 2: Extrapolate by using the derivative at the first/last table points if outside of the table scope. (If smoothness is LinearSegments or ConstantSegments this means to extrapolate linearly through the first/last two table points.). = 3: Periodically repeat the table data (periodical function). = 4: No extrapolation, i.e. extrapolation triggers an error
The table matrix can be defined in the following ways:
tableName is "NoName" or has only blanks, fileName is "NoName" or has only blanks.
or Scilab by commandsave tables.mat tab1 tab2 tab3
when the three tables tab1, tab2, tab3 should be used from the model.savematfile tables.mat tab1 tab2 tab3
When the constant "NO_FILE_SYSTEM" is defined, all file I/O related parts of the source code are removed by the C-preprocessor, such that no access to files takes place.
If the table is read from a CSV file, the following limitations apply
If tables are read from a text file, the file needs 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" (a line comment defining the version number of the file format). Afterwards, the corresponding matrix has to be declared with type (= "double" or "float"), name and actual dimensions. A valid matrix name (e.g., "tab1") must be ASCII encoded and not contain blanks, line breaks, tab (\t), comma (,) or parentheses. Finally, in successive rows of the file, the elements of the matrix have to be given. The elements have to be provided as a sequence of numbers in row-wise order (therefore a matrix row can span several lines in the file and need not start at the beginning of a line). Numbers have to be given according to C syntax (such as 2.3, -2, +2.e4). Number separators are spaces, tab (\t), comma (,), or semicolon (;). Several matrices may be defined one after another. Line comments start with the hash symbol (#) and can appear everywhere. Text files should either be ASCII or UTF-8 encoded, where UTF-8 encoded strings are only allowed in line comments and an optional UTF-8 BOM at the start of the text file is ignored. Other characters, like trailing non comments, are not allowed in the file.
MATLAB is a registered trademark of The MathWorks, Inc.