Using Simulink     Search    Help Desk 
From File

Read data from a file.

Library

Sources

Description

The From File block outputs data read from the specified file. The block icon displays the name of the file supplying the data.

The 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 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 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 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 file into memory at the start of the simulation. As a result, you cannot read data from the same 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 file:

Data Type Support

A From File block outputs real signals of type double.

Parameters and Dialog Box

File name
The name of the file that contains the data used as input. The default file name is untitled.mat.
Sample time
Sample rate of data read from the file.

Characteristics

Sample Time
Inherited from driven block
Scalar Expansion
No
Vectorized
Yes
Zero Crossing
No



[ Previous | Help Desk | Next ]