SimulationInput needs slx vs mdl file

6 visualizaciones (últimos 30 días)
Michael Kane
Michael Kane el 9 de Abr. de 2019
Comentada: Michael Kane el 17 de Mayo de 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.

Respuesta aceptada

Michael Kane
Michael Kane el 9 de Abr. de 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 comentarios
Krishna T Medam
Krishna T Medam el 17 de Mayo de 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 el 17 de Mayo de 2020
Is you .slx file a valid Matlab file name?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by