I got Error using vertcat Dimensions of arrays being concatenated are not consistent. Error in Code_tubes (line 22) C = [q(1); q(2); q(3);

조회 수: 3 (최근 30일)
I try to do compitational kinematic analysis, but when i write the driving constrain, this error occur, i dont have any idea about whats wrong in my line. Please somebody help me
d = 27.5; %cm
l2 = 31; %cm
l3 = 37; %cm
l4 = 38.5; %cm
w2 = 2; %rad/s
teta2_o = pi/2; %rad
t = 0:0.001:2;
Numdata = size(t,2);
%Matrix coordinate
q = zeros(12,1);
q_all = zeros(12,Numdata);
qdot_all = zeros(12,Numdata);
qdot2_all = zeros(12,Numdata);
uC = zeros(2,1);
rC_all = zeros(2,Numdata);
for j = 1:Numdata
for i = 1:3 %number of iteration
%Constrain matrix
C = [q(1); q(2); q(3);
q(4) - (l2*cos(q(6)))/2;
q(5) - (l2*sin(q(6)))/2;
q(4) + (l2*cos(q(6)))/2 - q(7) + (l3*cos(q(9)))/2;
q(5) + (l2*sin(q(6)))/2 - q(8) + (l3*sin(q(9)))/2;
q(7) - q(10) + (l4*cos(q(12)))/2;
q(8) - q(11) + (l4*sin(q(12)))/2;
q(10) + (l4*cos(q(12)))/2 - d;
q(11) + (l4*sin(q(12)))/2;
q(6) - teta2_o - w2*t];

채택된 답변

Joseph Cheng
Joseph Cheng 2021년 11월 9일
a quick scan shows it at the last row of C with
q(6) - teta2_o - w2*t];
where everything up to that looks to be a 1x1 large as you're indexing through q for 1 index but then you have t which is defined as
t = 0:0.001:2;
so you cant squeeze something that wide into a single index array entry.
Also it doesn't look like you're doing anything using the i and j for the for loop but that is another question
  댓글 수: 1
Fauzanul Ardhi
Fauzanul Ardhi 2021년 11월 9일
thanks a lot, it works, so i supposed to use t(j), intsead of t. tho i still have error in other line, hope i will figure it out somehow

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

추가 답변 (0개)


Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기





Community Treasure Hunt

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

Start Hunting!

Translated by