Filter löschen
Filter löschen

How can i load data from workspace to simulink

1 Ansicht (letzte 30 Tage)
Anas Alahdab
Anas Alahdab am 7 Mär. 2020
Kommentiert: Ameer Hamza am 1 Apr. 2020
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?

Antworten (2)

Ameer Hamza
Ameer Hamza am 7 Mär. 2020
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 am 1 Apr. 2020
Thank you

Kategorien

Mehr zu Modeling finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by