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!