Effacer les filtres
Effacer les filtres

How can i load data from workspace to simulink

1 vue (au cours des 30 derniers jours)
Anas Alahdab
Anas Alahdab le 7 Mar 2020
Commenté : Ameer Hamza le 1 Avr 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?

Réponses (2)

Ameer Hamza
Ameer Hamza le 7 Mar 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 le 1 Avr 2020
Thank you

Catégories

En savoir plus sur Modeling dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by