Clear Filters
Clear Filters

SimulationInput needs slx vs mdl file

7 views (last 30 days)
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.

Accepted Answer

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

Sign in to comment.

More Answers (0)

Categories

Find more on Create Large-Scale Model Components in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!