'InitFcn' callback error

123 views (last 30 days)
Mariam Dabbous
Mariam Dabbous on 1 Mar 2020
Commented: Walter Roberson on 8 Jun 2022
I was trying to design and tune a MPC controller for a MIMO system and I keep getting the following error.
This is my Simulink block diagram:
When I right-click and select model properties, callbacks, and 'InitFcn', this is what I get:
  6 Comments
Jonah Embry-Seckler
Jonah Embry-Seckler on 13 Apr 2020
Additionally, the exact error appears to occur on line 14 in this line:
mpcobj = slResolve(mpcobjname,blk)
slResolve cannot resolve mpc1. What is slResolve? It doesn't appear to be a standard Matlab function based on my google searches.
Walter Roberson
Walter Roberson on 29 May 2021
slResolve() is probably the internal Simulink symbol resolution; https://www.mathworks.com/help/simulink/ug/resolving-symbols.html

Sign in to comment.

Accepted Answer

Samuel Folorunsho
Samuel Folorunsho on 8 Jun 2021
The probelem is that you did not save the mpc controller as a mat file that could be called once you exit the designer. So once you clear your workplace , the exported controller is no longer available on the workplace resulting in the error. To resolve this, you will need to:
  1. Save the controller after exporting it : save('mpc1.mat','mpc1'). Here mpc1 is the name of the controller as speficied by you while designing it
  2. Include the code to call the saved controller in your MATLAB file: load('mpc1'). This will load the controller into your workspace and your model will run without the error.
I hope this helps
reference: https://www.mathworks.com/matlabcentral/answers/403735-how-to-save-mpc-model-predictive-controller-to-be-used-later-on-the-error-message-is-attached
  1 Comment
Javier Pastor
Javier Pastor on 1 Jan 2022
Thank you very much! I was facing the same problem!

Sign in to comment.

More Answers (3)

Wissal Tabib
Wissal Tabib on 29 May 2021
did you find a solution to your problem what was it ? I am facing the same

Adesola Bankole
Adesola Bankole on 23 Apr 2022
Make sure that the 'clear' or 'clear all' syntax is either commented or deleted.
The issue should be resolved with that action

Guilherme Vitor Santos
Guilherme Vitor Santos on 3 Jun 2022
Edited: Guilherme Vitor Santos on 3 Jun 2022
Estous com esse problema no matlab online
Error evaluating 'InitFcn' callback of Audio Device Writer block (mask) 'labtelecom/Audio Device Writer'.
Callback string is 'audioblkAudioDeviceIO(gcbh, 'initfcn');'
Caused by:
No audio input device detected
  3 Comments
Ashlesh
Ashlesh on 8 Jun 2022
I have the same issue ..how can I resolve it?
Walter Roberson
Walter Roberson on 8 Jun 2022
Ashlesh, are you using Chrome to access MATLAB Online? No other browser can possibly work.

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!