Error evaluating 'InitFcn' callback of block_diagram 'SIMULINK_MODEL'. Callback string is 'MATLAB_MODEL' Caused by: Error using MATLAB_MODEL

47 Ansichten (letzte 30 Tage)
Hello everyone,
I am trying to link MatLab with ModeFrontier but I need to automatically get the results of the Simulink model in MatLab. Searching online, I found the Sim command but it gives me error (see below).
I write in MatLab 'sim("SIMULINK_MODEL", stop_time)'
The error is: Error evaluating 'InitFcn' callback of block_diagram 'SIMULINK_MODEL_v20180919'.
Callback string is 'MATLAB_MODEL_v20180919'
Caused by:
Error using MATLAB_MODEL_v20180919
Cannot start a new command line simulation while an update diagram or a simulation has started for
the same model
If I click in 'InitFcn', it opens the Model Properties tab of Simulink where I can see that the Matlab model is used as model initialization function (InitFcn). Please, does anyone have an idea how I can solve the issue or get the data in MatLab differently?

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 13 Mär. 2023
Most likely, it is looking for a file named "MATLAB_MODEL_v20180919.m". Search for that file and check if the folder is in your MATLAB path.
You could also try this. Start MATLAB, open your simulink model, click "Play" to run simulation. The same error probably will happen. You need to follow the same approach above to resolve it.
  2 Kommentare
Gabriella
Gabriella am 13 Mär. 2023
Hello, thank you for your answer. Yes, the model name is 'MATLAB_MODEL_v20180919.m' (I just wanted to shorten it for the title of the question).
The model runs correctly if I run MatLab and then I run Simulink but I need to make it automatically.
Fangjun Jiang
Fangjun Jiang am 13 Mär. 2023
" Cannot start a new command line simulation while an update diagram or a simulation has started for
the same model"
Maybe you have a circular calling sequence? If your manuall process works properly, then all you need to make it automatic is to create a new .m file and add these lines
ModelName='SIMULINK_MODEL_v20180919';
open_system(ModelName);
output=sim(ModelName);

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulink Environment Customization finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by