Inputting Data from my workspace into Simulink

3 views (last 30 days)
Sean O'Kane
Sean O'Kane on 13 Oct 2021
I have a data series I would like to input into Simulink that has been calculated within my Matlab workspace, when I use the "From fworkspace" block I get these errors:
Unsupported input format for From Workspace block 'FC_Simulink_Model_V2/From Workspace'. Available formats are double non-complex matrix, a structure with or without time, or a structure with MATLAB timeseries as leaf nodes. All formats require the data to be finite (not Inf or NaN).
Component:Simulink | Category:Model error
Invalid matrix variable specified as workspace input in 'FC_Simulink_Model_V2/From Workspace1'. The matrix data must be a real, double, have two dimensions, and at least two columns. The first column must contain time values and the remaining columns the data values. Matrix values cannot be Inf or NaN.
Component:Simulink | Category:Model error
I think this is due to the fact that the data series doesn't have a time stamp and is just one column of 1Hz data. I removed the time stamp earlier on in the Matlab processes as some data was redundant and had to be removed. I am hoping to be able to input this data as it is, but I am unsure of the block settings, etc. that will allow me to input the data.
  3 Comments
Mathieu NOE
Mathieu NOE on 13 Oct 2021
you should do this in your initialisation script (if you have done one)
it's fairly simple to create a time vector if you know how many samples and the time increment / sampling frequency

Sign in to comment.

Answers (1)

Harikrishnan Balachandran Nair
Hi,
I understand that you are having a 1-D array in your base workspace, that you want to import to your simulink model.
If the input is not a time-series, you can directly use the 'constant' block, with the variable name specified in the 'Constant value' field, inside the block parameters. In this case,according to your model, you will get a 2558*1 array as input at each time-step.
If you want the input as a time-series, you may use the 'from workspace' block, with the input format being in one of the supported formats specified here : https://www.mathworks.com/help/simulink/ug/load-data-using-the-from-workspace-block.html#d123e200736
As an example, in the provided case, you can easily make a time-series object with the data that you have in the workspace, and the sampling time of the model. As an example, if sampleTime=0.01, and number of steps taken is 2558 , the following code can be used before running the model.
sampleTime = 0.01;
numSteps = 2558;
time = sampleTime*(0:numSteps-1);
time = time';
Engine_power=timeseries(Engine_powerdata,time);
You can refer to the documentation provided to get a better idea on the 'From Workspace' block.

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!