Is it possible to pass simulink NMPC parameters as struct?

10 Ansichten (letzte 30 Tage)
Currently I am developing a NMPC controller and the functions used for the algorithm (state definition, cost, etc.) make use or a broad array of parameters.
In Matlab I have used a structure to pass the parameters without problem, e.g.:
p.param1 = 2
p.param2 = 3
p.param3 = 4
nloptions = nlmpcmoveopt
nloptions.Parameters = {p} % <--- works without a problem with nlmpcmove
While implementing the controller on Simulink I have found that the parameters should be given using a "Bus Creator" which should be predefined in Matlab with createParameterBus. This doesn´t allow the use of "struct".
I tried encapsulating my structure in a cell array but to no avail. When using my structure as a constant to the bus creator I get the following error:
Invalid setting in 'Bus Creator1' for parameter 'OutDataTypeStr'.
Caused by:
Error evaluating properties of Simulink.Bus object 'busNPC_2' in workspace 'base' (used by block 'Bus Creator1')
Error evaluating DataType property.
Not enough input arguments.
Component:Simulink | Category:Block error
If I cannot use the structure I would have to pass the parameters separately to the functions (e.g. fun1(x,u, p1, p2, p3, p4, .......))
This would be rather bothersome and unappealing.
Any help/suggestions provided are really appreciated :)
  4 Kommentare
Eduardo
Eduardo am 9 Jan. 2023
The function ended up heavily slowing the simulation.
Right now I am trying to input the parameters as a cell array with the bus creator but I do not seem to be able to correctly use them in my state function......
Osamah Ali Mohammed Saad
Osamah Ali Mohammed Saad am 5 Mär. 2024 um 10:21
Hi Eduardo,
Have you found a solution for this problem yet?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Emmanouil Tzorakoleftherakis
Please take a look at my answer here

Weitere Antworten (0)

Kategorien

Mehr zu Model Predictive Control Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by