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

조회 수: 22 (최근 30일)
Chanho Ko
Chanho Ko 2020년 2월 21일
답변: Jakobus Louw 2020년 4월 9일
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에서 Controller Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by