필터 지우기
필터 지우기

How can i load data from workspace to simulink

조회 수: 1 (최근 30일)
Anas Alahdab
Anas Alahdab 2020년 3월 7일
댓글: Ameer Hamza 2020년 4월 1일
Hallo,
I am trying to export a Excel-file to Simulink. So, I download the table in Matlab / workspace. So I created a variable through this code
"resultsFile = 'example.xlsx';
example2019 = readtable(resultsFile);".
the code create a variable in the workspace.
this variable is in a table format. afterthat, i convert this table to struct.
when i use the block 'from workspace' i get an error message "invalid structure-format variable specified as workspace input in 'untitled/From Workspace'. The input structure must be scalar.",
in the example you can see a little part from my data in the table, because my orginal table contain 35041row and 2 column .
how can i solve this problem, please?

답변 (2개)

Ameer Hamza
Ameer Hamza 2020년 3월 7일
An easy way is to import the data as a numeric array instead of structure or time series. The numeric array is imported using constant block. Check the example in the attached Simulink file.
First run these lines
resultsFile = 'example.xlsx';
example2019 = readtable(resultsFile);
power = example2019.Power_KW_;
and then run the simulink model. The simulink model will iterate through all the values in power array.
The .mdl file is also attached in case there is a compatability issue between versions of Simulink.

Anas Alahdab
Anas Alahdab 2020년 4월 1일
Thank you

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by