SimulationInput needs slx vs mdl file

6 visualizzazioni (ultimi 30 giorni)
When trying to run an .mdl file as follows, I received the following error.
>> in = Simulink.SimulationInput('myModel.mdl');
>> sim(in)
Invalid block diagram name supplied. Valid block diagram names are the same as valid MATLAB variable names. Type "help
isvarname" for more information.
This occurs eventhough myModel.mdl runs fine in the old Simulink syntax
>> sim('myModel.mdl')
I found that this error is pretty meaningless, and occurs even if the file does not exist. For example,
>> in = Simulink.SimulationInput('nonexistentModel.mdl');
>> sim(in)
returns the same Invalid block diagram error.

Risposta accettata

Michael Kane
Michael Kane il 9 Apr 2019
After a lucky guess, I found that if I converted the *.mdl file to the newer *.slx file, then the code ran as intended.
The documentation for SimulationInput should be changed to state that it requires *.slx models.
I hope this post helps someone else someday with the same problem
  2 Commenti
Krishna T Medam
Krishna T Medam il 17 Mag 2020
Hi Michael, What if I get this error with simulink model that has .slx extension? Model is created in 2019 version and I am trying to open in 2017. Is that the reason for this error?
Michael Kane
Michael Kane il 17 Mag 2020
Is you .slx file a valid Matlab file name?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Create Large-Scale Model Components in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by