Simulink Reference Previous page   Next Page
From File

Read data from a MAT file.

Library

Sources

Description


The From File block outputs data read from a MAT file. Its icon displays the pathname of the file supplying the data.

The MAT file must contain a matrix of two or more rows. The first row must contain monotonically increasing time points. Other rows contain data points that correspond to the time point in that column. The matrix is expected to have this form.

The width of the output depends on the number of rows in the MAT file. The block uses the time data to determine its output, but does not output the time values. This means that in a matrix containing m rows, the block outputs a vector of length m-1, consisting of data from all but the first row of the appropriate column.

If an output value is needed at a time that falls between two values in the MAT file, the value is linearly interpolated between the appropriate values. If the required time is less than the first time value or greater than the last time value in the MAT file, Simulink extrapolates, using the first two or last two points to compute a value.

If the matrix includes two or more columns at the same time value, the output is the data point for the first column encountered. For example, for a matrix that has this data:

At time 2, the output is 4, the data point for the first column encountered at that time value.

Simulink reads the MAT file into memory at the start of the simulation. As a result, you cannot read data from the same MAT file named in a To File block in the same model.

Using Data Saved by a To File or a To Workspace Block

The From File block can read data written by a To File block without any modifications.

To read data written by a To Workspace block and saved to a MAT file:

Data Type Support

The From File block outputs real signals of type double.

Parameters and Dialog Box

Opening this dialog box causes a running simulation to pause. See Changing Source Block Parameters in the online Simulink documentation for details.

File name
The fully qualified pathname or file name of the MAT file that contains the data used as input. On UNIX, the pathname can start with a tilde (~) character signifying your home directory. The default file name is untitled.mat. If you specify an unqualified file name, Simulink assumes that the MAT file resides in the MATLAB working directory. (To determine the working directory, enter pwd at the MATLAB command line.) If Simulink cannot find the specified file name in the working directory, it displays an error message.
Sample time
The sample period and offset of the data read from the file. See Specifying Sample Time in the online documentation for more information.

Characteristics

Sample Time
Specified in the Sample time parameter
Scalar Expansion
No
Dimensionalized
1-D array only
Zero Crossing
No


Previous page  From From Workspace Next page

© 1994-2005 The MathWorks, Inc.