Error in port widths or dimensions.

686 views (last 30 days)
Leo Sekar
Leo Sekar on 16 Oct 2015
Answered: Munna on 9 Aug 2024
Error in port widths or dimensions. Output port 1 of 'last/Subsystem/powergui/EquivalentModel1/Gates/From2' is a one dimensional vector with 2 elements.
AND
Error in port widths or dimensions. Invalid dimension has been specified for input port 2 of 'last/Subsystem/powergui/EquivalentModel1/Gates/Mux'.
I am using MATLAB 2010a. problem occurred in the switching circuit of invert. Anticipating your answers...
  5 Comments
Munna
Munna on 9 Aug 2024
function [M,V,G,F] = fcn(q3,q4,qd1, qd2, qd3, qd4, qd5)
%#codegen
% Parameters considered in the manipulator.
l2 = 0.2; l3 = 0.2; l4 = 0.2;
lc2 = 0.0229; lc3 = 0.0229; lc4 = 0.02229;
m1 = 1.228; m2 = 1.023; m3 = 1.023; m4 = 1.023; m5 = 0.5114;
I2zz = 0.0058; I3zz = 0.0058; I4zz = 0.0058;
Fv1 = 0.03; Fv2 = 0.025; Fv3 = 0.025; Fv4 = 0.025; Fv5 = 0.02;
gz = 9.8;
% Inertia Matrix M
M11 = m1 + m2 + m3 + m4 + m5;
M12 = 0; M21 = 0; M13 = 0; M31 = 0; M41 = 0; M14 = 0; M25 = 0;
M35 = 0; M53 = 0; M52 = 0; M45 = 0; M54 = 0;
M15 = -m5;
M51 = -m5;
M22 = lc2^2*m2 + (l2^2 + lc3^2 + 2*l2*lc3*cos(q3))*m3 + ...
(l2^2 + l3^2 + lc4^2 + 2*l2*l3*cos(q3))*m4 + ...
2*(l3*lc4*cos(q4) + l2*lc4*cos(q3+q4))*m4 + ...
(l2^2 + l3^2 + l4^2 + 2*l2*l3*cos(q3))*m5 + ...
2*(l3*l4*cos(q4) + l2*l4*cos(q3+q4))*m5 + I2zz + I3zz + I4zz;
M23 = (lc3^2 + l2*lc3*cos(q3))*m3 + ...
(l3^2 + lc4^2 + l2*l3*cos(q3) + 2*l3*lc4*cos(q4))*m4 + ...
(l2*lc4*cos(q3+q4))*m4 + ...
(l2*l4*cos(q3+q4))*m5 + ...
(l3^2 + l4^2 + l2*l3*cos(q3) + 2*l3*l4*cos(q4))*m5 + I3zz + I4zz;
M32 = M23; % Symmetric property
M24 = (lc4^2 + l3*lc4*cos(q4) + l2*lc4*cos(q3+q4))*m4 + ...
(l4^2 + l3*l4*cos(q4) + l2*l4*cos(q3+q4))*m5 + I4zz;
M42 = M24; % Symmetric property
M33 = lc3^2*m3 + (l3^2 + lc4^2 + 2*l3*lc4*cos(q4))*m4 + ...
(l3^2 + lc4^2 + 2*l2*l4*cos(q4))*m5 + I3zz + I4zz;
M34 = (lc4^2 + l3*lc4*cos(q4))*m4 + (l4^2 + l3*l4*cos(q4))*m5 + I4zz;
M43 = M34; % Symmetric property
M44 = lc4^2*m4 + l4^2*m5 + I4zz;
M55 = m5;
M = [M11 M12 M13 M14 M15; M21 M22 M23 M24 M25; ...
M31 M32 M33 M34 M35; M41 M42 M43 M44 M45; ...
M51 M52 M53 M54 M55];
% Coriolis and Centrifugal Matrix V
Vm11 = 0; Vm12 = 0; Vm13 = 0; Vm14 = 0; Vm15 = 0; Vm21 = 0; Vm25 = 0;
Vm31 = 0; Vm35 = 0; Vm41 = 0; Vm44 = 0; Vm45 = 0; Vm51 = 0; Vm52 = 0;
Vm53 = 0; Vm54 = 0; Vm55 = 0;
Vm22 = -(lc3*m3 + l3*m4 + l3*m5)*l2*sin(q3)*qd3 + ...
(l2*sin(q3+q4)*qd3 - (l3*sin(q4) + l2*sin(q3+q4)*qd4)*(lc4*m4 + l4*m5));
Vm23 = -(lc3*m3 + l3*m4 + l3*m5)*l2*sin(q3)*qd2 - ...
(lc4*m4 + l4*m5)*l2*sin(q3+q4)*qd2 - ...
((lc3*m3 + l3*m4 + l3*m5)*l2*sin(q3)*qd3) - ...
(lc4*m4 + l4*m5)*l2*sin(q3+q4)*qd3 - ...
((lc4*m4 + l4*m5)*(l3*sin(q4) + l2*sin(q3+q4))*qd4);
Vm24 = -(lc4*m4 + l4*m5)*(l3*sin(q4) + l2*sin(q3+q4)*(qd2 + qd3 + qd4));
Vm32 = (lc3*m3 + l3*m4 + l3*m5)*l2*sin(q3)*qd2 + ...
(lc4*m4 + l4*m5)*l2*sin(q3+q4)*qd2 - ...
(lc4*m4 + l4*m5)*l3*sin(q4)*qd4;
Vm33 = -(lc4*m4 + l4*m5)*l3*sin(q4)*qd4;
Vm34 = -(lc4*m4 + l4*m5)*l3*sin(q4)*(qd2 + qd3 + qd4);
Vm42 = (lc4*m4 + l4*m5)*(l2*sin(q3+q4) + l3*sin(q4))*qd2 + ...
(lc4*m4 + l4*m5)*l3*sin(q4)*qd3;
Vm43 = (lc4*m4 + l4*m5)*l3*sin(q4)*(qd2 + qd3);
V = [Vm11 Vm12 Vm13 Vm14 Vm15; Vm21 Vm22 Vm23 Vm24 Vm25; ...
Vm31 Vm32 Vm33 Vm34 Vm35; Vm41 Vm42 Vm43 Vm44 Vm45; ...
Vm51 Vm52 Vm53 Vm54 Vm55];
% Friction Vector F and Gravity Vector G
F = [Fv1*qd1 Fv2*qd2 Fv3*qd3 Fv4*qd4 Fv5*qd5];
G = [(m1 + m2 + m3 + m4 + m5)*gz ; 0 ; 0; 0; -m5 * gz].';
end
this is my code

Sign in to comment.

Accepted Answer

Dennie
Dennie on 16 Oct 2015
Hello Leo,
It is difficult to see from the pictures, but it looks like you have predefined the sizes of your signals. The dimensions of the signals going into the mux is not matching with what Simulink is expecting from the output. You can check this by double clicking on the problematic blocks and see which rule Simulink uses to determine the size and type of the signal.
To me it looks like the state space block is expecting a signal of the size 10x1, and the signal given to the mux is larger than that.
Kind regards,
Dennie
  5 Comments
sandesh khadka
sandesh khadka on 1 Dec 2020
can you suggest me hall decoder for bldc motor
sandesh khadka
sandesh khadka on 9 Dec 2020
i have tried that option also. i can't get answer

Sign in to comment.

More Answers (4)

Joel Van Sickel
Joel Van Sickel on 10 Jun 2024
It seems like question is getting a lot of activity, so I'll post another answer here. The issue with this type of port width issue has to do with using specialized power systems. Under the hood, ALL of the simulink signals going into your circuit go into a single simulink s -funciton. So this means all gate signals, any signals to controlled sources, any voltages torques, speeds, etc, going into machines. If you get this error, it means that your simulink model is putting the incorect size signal into the model. For instance, the model at the very top is having vectorized signals go into the gate port of a switch. The gate port of a switch only takes 1 signal. However, some other prebuilt converters might take additional signals. Unfortunately, the way specialized power systems works can make tracking this down a bit harder, and you need to pay close attention to the input sizes of all the ports. If you want to avoid this problem, you can use simscape (the blue components) and you won't have the issue, or if you do, it will point more specifically to where the problem is.

sandesh khadka
sandesh khadka on 1 Dec 2020
Invalid setting for input port dimensions of 'BLDC/DECODER/Demux1'. The dimensions are being set to [-1]. This is not valid because the total number of input and output elements are not the same
  9 Comments
Muhammad Kamran Mustafa
Muhammad Kamran Mustafa on 14 Jun 2023
Moved: DGM on 2 Dec 2023
how to solve this error ?
Urveshkumar Dharmendrabhai
Moved: DGM on 2 Dec 2023
I am also facing the same problem..kindly let me know if anybody of you have got the solution

Sign in to comment.


Haftamu Lemlem
Haftamu Lemlem on 2 Dec 2023
Edited: Haftamu Lemlem on 2 Dec 2023
i know how irritating this error could be. i also encountered the same error just yesterday and i am giving this incase someone found it helpful. i was running a delta connected CHB STATCOM and got this error repeatedly. i looked for some solutions including this very page. it might be helpful for some people but it wasnt very helpful for me. this error maybe caused because of many reasons and mine was because of the a PWM generator. i used three level PWM generator after the inverse park transformation to help me generate signals for the IGBT switches. but it turns out that the PWM generator generates 12 pulses for each phase which i connected using one line. That was the mistake and it was solved as soon as i removed the PWM from the model. so there is different reasons for this error. so just focus on your model and put each and every part carefully and reasonably.
Cheers!
Haftamu!
  2 Comments
Nihal Shaji
Nihal Shaji on 20 Mar 2024
I am doing something very similar involving Field Oriented Control of a PMSM, and the connections of the FOC is giving me the same error. I used a normal PWM instead of a two level but it still didn't solve itself. Did you try anything else?
laiche zeghdi
laiche zeghdi on 24 Mar 2024
i also have same problem but i got this :''Error in port widths or dimensions. Output port 1 of 'Stat_Chikh_2_trois_niv/powergui/EquivalentModel1/Gates/From27' is a [1x2] matrix.''
and this :''Error in port widths or dimensions. Invalid dimension has been specified for input port 27 of 'Stat_Chikh_2_trois_niv/powergui/EquivalentModel1/Gates/Mux'.''
help me

Sign in to comment.


Munna
Munna on 9 Aug 2024
Error in port widths or dimensions. Output port 1 of 'fivedof_pids/MATLAB Function' is a [5x5] matrix.
Component: Simulink | Category: Block error

Categories

Find more on Electrical Block Libraries in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!