SimulationInput needs slx vs mdl file

7 次查看(过去 30 天)
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.

采纳的回答

Michael Kane
Michael Kane 2019-4-9
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 个评论
Krishna T Medam
Krishna T Medam 2020-5-17
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 2020-5-17
Is you .slx file a valid Matlab file name?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Create Large-Scale Model Components 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by