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

13 次查看(过去 30 天)
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;

回答(3 个)

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

Sai Sri Pathuri
Sai Sri Pathuri 2020-2-25
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 2020-3-12
You can use Signal Dimension block to mention the dimension as [5 2] to ensure that there is no discrepency.

类别

Help CenterFile Exchange 中查找有关 Refinement 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by