|On this page…|
You can use a MATLAB® time expression to import data from a workspace. To use a time expression, enter the expression as a string (i.e., enclosed in single quotes) in the Input field of the Data Import/Export pane. The time expression can be any MATLAB expression that evaluates to a row vector equal in length to the number of signals entering the input ports of the model. For example, suppose that a model has one vector Inport that accepts two signals. Furthermore, suppose that timefcn is a user-defined function that returns a row vector two elements long. The following are valid input time expressions for such a model:
'[3*sin(t), cos(2*t)]' '4*timefcn(w*t)+7'
The expression is evaluated at each step of the simulation, applying the resulting values to the model's input ports. Note that the Simulink® software defines the variable t when it runs the simulation. Also, you can omit the time variable in expressions for functions of one variable. For example, the expression sin is interpreted as sin(t).