Search code examples
workspacematlabsimulink

matlab "from workspace" block has error


If have an array (5000x1 double) in matlab workspace. I put the 'from workspace' block in simulink window for input of another block, But when run the program this error occurred:

Invalid matrix-format variable specified as workspace input in 'new_net_pattern_recog/From Workspace'. The matrix must have two dimensions and at least two columns. Complex signals of any data type and non-double real signals must be in structure format. The first column must contain time values and the remaining columns the data values. Matrix values cannot be Inf or NaN.

What can I do?


Solution

  • I believe that you are getting this error because the From Workspace block is expecting your data to be in the form of a time series. According to the documentation for this block,

    In the Data parameter of the block, enter a MATLAB expression that specifies the workspace data. The expression must evaluate to one of the following:

    • A MATLAB timeseries object
    • A structure of MATLAB timeseries objects
    • An array or structure containing an array of simulation times and corresponding signal values

    It sounds like your 5000x1 element array does not change over time, and these values are intended to remain constant throughout the entirety of the simulation. If this is true, then you should just use a Constant block. To use a variable from the workspace as the output of this block, simply set the "Constant Value" parameter of the constant block to the name of your variable. Refer to this doc for more info on the Constant block.