'Error in port widths or dimensions' for using Adaptive MPC controller

23 visualizaciones (últimos 30 días)
Chanho Ko
Chanho Ko el 21 de Feb. de 2020
Respondida: Jakobus Louw el 9 de Abr. de 2020
I'm trying to construct the Co-simulation environment of path planning using MPC with CarSim.
but I'm struggle with debugging some errors. In the above simulink code, it makes a one Block error that says right below
"Error in port widths or dimensions. The signal connected to the "Model.B" port of the "Base_Model/Adaptive MPC Controller" block must be a matrix signal of 5 rows and 2 columns."
I don't definitley make sense since I think that the size of matix B is [5x2] as you can see above picture.
In addition, here is the Matlab Function code for generating state space matrix for updating model on adaptive MPC.
function [A,B,C,D,U,Y,X,DX] = fcn(x,u)
% Sample time
Ts = 0.1;
% Continuous-Time model
coder.extrinsic('linmod');
[Ac,Bc,Cc,Dc] = linmod('vehicleModel',x,u);
% Discretize using zero-order hold
nx = 5; nu = 2;
temp = coder.nullcopy(zeros(7,7));
A = coder.nullcopy(zeros(5,5));
B = coder.nullcopy(zeros(5,2));
C = coder.nullcopy(zeros(2,5));
D = coder.nullcopy(zeros(2,2));
X = coder.nullcopy(zeros(5,1));
U = coder.nullcopy(zeros(2,1));
Y = coder.nullcopy(zeros(2,1));
DX = coder.nullcopy(zeros(5,1));
% nx = size(Ac,1);
% nu = size(Bc,2);
temp = expm([[Ac Bc]*Ts; zeros(nu,nx+nu)]);
A = temp(1:nx, 1:nx);
B = temp(1:nx, nx+1:nx+nu);
C = Cc;
D = Dc;
% Nominal conditions of DT plant
X = x;
U = u;
Y = C*x;
DX = A*x + B*u - x;

Respuestas (3)

Jakobus Louw
Jakobus Louw el 9 de Abr. de 2020
Its similar to Dhruv's answer, but the block is called SIgnal Specification.

Sai Sri Pathuri
Sai Sri Pathuri el 25 de Feb. de 2020
The Bus Creator block you are using in the model combines all the output signals from ML function block. But the expected input of Adaptive MPC block is not the entire bus signal. So, you may use Bus Selector block to select the appropriate signal from the bus signal.

Dhruv Thakkar
Dhruv Thakkar el 12 de Mzo. de 2020
You can use Signal Dimension block to mention the dimension as [5 2] to ensure that there is no discrepency.

Categorías

Más información sobre Controller Creation en Help Center y File Exchange.

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by