フィルターのクリア

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
  1 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 4 月 1 日
Glad to be of help.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by