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 Kommentare

Walter Roberson
Walter Roberson am 1 Mär. 2020
You need to look at the properties of m_p_c/MPC_Controller
Mariam Dabbous
Mariam Dabbous am 1 Mär. 2020
This is what I get:
Walter Roberson
Walter Roberson am 2 Mär. 2020
That is what I expected you would get: that is what the error message said you would find there.
The problem is that impcblock_initFcn needs to use mpc1 inside it, but mpc1 is not defined.
I cannot tell from the messages whether mpc1 is intended to be a block, or a model, or a constant parameter, or a variable that is defined inside the base workspace, or something else.
The name mpc1 hints that possibly at one time the the mpc model was renamed to mpc1 and that the code in impcblock_initFcn was not adjusted back to refer to mpc . But that is speculation. You need to find impcblokc_initFcn and examine the code there.
Jonah Embry-Seckler
Jonah Embry-Seckler am 13 Apr. 2020
I am having the exact same problems as described above. I found the impcblock_InitFcn file using my command window, and tried to run it in the standard IDE. It indicated that there was an error using mpc_chkmpcobjxmpc: it couldn't resolve mpc1. This makes sense since mpc_chkmpcobjxmpc is the utility function which obtains @mpc and @mpcstate objects from the block diagram. However, when I go to edit mpc_chkmpcobjxmpc, it says syas that I do not have enough input arguments. The error is called on line 10. Additionally, when I attempt to edit the file, Matlab doesn't let me save or compile anything. I am not sure what to do next.
For reference, I am running R2019a. I downloaded the MPC Simulink package this morning after having had Matlab R2019a for several months prior. Not sure if this makes a difference, but just incase.
Thanks!
Jonah Embry-Seckler
Jonah Embry-Seckler am 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 am 29 Mai 2021
slResolve() is probably the internal Simulink symbol resolution; https://www.mathworks.com/help/simulink/ug/resolving-symbols.html

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Samuel Folorunsho
Samuel Folorunsho am 8 Jun. 2021

1 Stimme

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 Kommentar

Javier Pastor
Javier Pastor am 1 Jan. 2022
Thank you very much! I was facing the same problem!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

Wissal Tabib
Wissal Tabib am 29 Mai 2021

0 Stimmen

did you find a solution to your problem what was it ? I am facing the same
Adesola Bankole
Adesola Bankole am 23 Apr. 2022

0 Stimmen

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 am 3 Jun. 2022
Bearbeitet: Guilherme Vitor Santos am 3 Jun. 2022

0 Stimmen

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 Kommentare

Walter Roberson
Walter Roberson am 3 Jun. 2022
MATLAB Online can only hope to find audio devices if you are using the Chrome browser to access it.
Ashlesh
Ashlesh am 8 Jun. 2022
I have the same issue ..how can I resolve it?
Walter Roberson
Walter Roberson am 8 Jun. 2022
Ashlesh, are you using Chrome to access MATLAB Online? No other browser can possibly work.

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by