SimulationInput needs slx vs mdl file

5 Ansichten (letzte 30 Tage)
Michael Kane
Michael Kane am 9 Apr. 2019
Kommentiert: Michael Kane am 17 Mai 2020
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.

Akzeptierte Antwort

Michael Kane
Michael Kane am 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 Kommentare
Krishna T Medam
Krishna T Medam am 17 Mai 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 am 17 Mai 2020
Is you .slx file a valid Matlab file name?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by