y = data(filename,column);
filename the filename of the data file
column the column number starting with 0 for the first column (time)
This function generates an output by linear interpolation of data read from file. The data on file is stored in columns. The first column contains the time values (t) and the second column contains the corresponding output values (y).
|•||The time data of the first column needs to be monotonically increasing.|
|•||Discontinuities are allowed, by providing the same time point twice in the table.|
|•||Values outside of the range, are computed by linear extrapolation of the last two points.|
The first argument (filename) of this function must be a parameter of the type string and is used as a reference to a filename. This reference can be specified using the complete path or relative to the model directory. The second argument (column) of this function must be a parameter of the type integer denoting a whole number. It is used to denote the column number.
The input file must be an ASCII (text) file or a Comma Separated Values (.csv) file and should consist at least two columns of data. The first column (number 0) should always contain the time values. The other columns (number 1, 2, 3, etc.) should contain the corresponding data values. The parameter column is used to specify which column is used for as output data.
The various values must be separated by a space, a tab or a comma. Each new set of time and data values must start on a new line. No comment or other text may be part of the file. The filename of the input file can be specified using the complete path (e.g. c:\data\data.tbl). When no path is given, the file is assumed to be in the same directory as your model.
The first row may contain names for the columns. Names should be indicated by quotation marks (").
string filename = 'data.txt';
integer col = 2;
y = data(filename,col);
Example data.txt file with header:
0.0, 1, 2
0.1, 5, 10
0.2, 6, 11
y must be a scalar. from_file must be string parameter. x must be an integer parameter.