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

d

5 commentaires

Hi Flavio,
your input to demux is a variable with 1 elements. How you are calculating your inputs or could you share some information about your logic inside subsystem block
VG
Ankit
Thanks for your answer. I have edited my question with more details.
it is very hard to decifer, logic seems fine. Is it possible to just attached ".slx or mdl" v2018b ?
try File --> Export Model to --> Previous Version -- 2018b
great :) what are the values of k_1 and k_2 ? how have you defined them?

Connectez-vous pour commenter.

 Réponse acceptée

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 commentaires

I am expecting the linear aln angular velocity to be 2x1 vectors, since I want to drive the unicycle to the origin, so at (x,y)=(0,0).
Thanks again
What is your problem now ? did you understand the difference between the two, % driving velocity
v=k_1*e_p*sag; and v=k_1*e_p.*sag; ?
Flavio Clarizia
Flavio Clarizia le 2 Oct 2020
Modifié(e) : Flavio Clarizia le 2 Oct 2020
Sorry i was answering the questions you posed. Thanks for the help.
Hi no problem.
you have to correctly define your inputs.
I tried the following:
function [input1,input2] = 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;
input1 = v;
input2 = omega;
As I am not aware to your problem statement but you just need to see your sizes of inputs and outputs are correct!
omega is a scalar or vector?
as you see your v is a vector and omega is a scalar currently. You are not allowed to do the following
input = [v;omega]; % Dimensions of arrays being concatenated are not consistent so you will get an error.
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

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by