Inputting Data from my workspace into Simulink
116 次查看(过去 30 天)
显示 更早的评论
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 个评论
Mathieu NOE
2021-10-13
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
回答(1 个)
Harikrishnan Balachandran Nair
2021-10-20
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!