# How do I solve "Error in port widths or dimensions" error in Simulink?

조회 수: 1(최근 30일)
Flavio Clarizia 2020년 10월 1일
편집: Flavio Clarizia 2020년 10월 3일
d
##### 댓글 수: 5표시숨기기 이전 댓글 수: 4
Ankit 2020년 10월 2일
great :) what are the values of k_1 and k_2 ? how have you defined them?

댓글을 달려면 로그인하십시오.

### 채택된 답변

Ankit 2020년 10월 2일
function input = C_REG(q)
% global k_1 k_2
x=q(1);
y=q(2);
theta=q(3);
e_p=[-x -y];
sag=[cos(theta);sin(theta)];
gamma=atan2(y,x)-theta+pi;
% driving velocity
v=k_1*e_p.*sag;
% steering velocity
omega=k_2*gamma;
input = [v;omega];
you have to careful with matrix/vector multiplication. your e_p [1 x2 ] and sag [2x1] --> multiplication of e_p and sag gives a matrix of [2x2] and multiply with k1 [1] results in a vector of [1x2] --> driving velocity
and similarly omega is a scalar.
Could you please explain what is your expected output ? steering velocity vector or scalar.
and similary driving velocity?
##### 댓글 수: 5표시숨기기 이전 댓글 수: 4
Ankit 2020년 10월 2일
try this. as you mentioned your v and omega are scalar following will work. let me know if it is clear now?
function input = C_REG(q)
global k_1 k_2
x=q(1);
y=q(2);
theta=q(3);
e_p=[-x -y];
sag=[cos(theta);sin(theta)];
gamma=atan2(y,x)-theta+pi;
% driving velocity
v=k_1*e_p*sag; % now it is scalar
% steering velocity
omega=k_2*gamma; % scalar
input = [v;omega]; % it is allowed

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by