Info
この質問は閉じられています。 編集または回答するには再度開いてください。
How can i fix ' Unable to perform assignment because the left and right sides have a different number of elements.' in the loop functions ?
2 ビュー (過去 30 日間)
古いコメントを表示
I got errors in Rdot, alpha3, Rdot2
R2= 16;
R3=33;
omega2= 3;
i=0;
j=0;
for theta2= 0:5:180;
theta2=theta2*pi/180;
i=i+1;
x(i)=theta2;
%position
theta3 = pi - asin(R2*sin(theta2)/R3);
R1(i)= (R2*cos(theta2) - R3*cos(theta3));
%velocity
omega3 (i) = (omega2*R2*cos(theta2))/(R3*cos(theta3));
Rdot(i) = (-R2*omega2*sin(theta2))+ (R3*omega3*cos(theta3));
%acceleration
alpha3 (i) = ((-omega2.^2)*R2*sin(theta2)+ (omega3.^2)*R3*sin(theta3))/R3*cos(theta3);
Rdot2(i) = -R2*(omega2^2)*cos(theta2) + R3*alpha3*sin(theta3) + R3*(omega3^2)*cos(theta3)
theta33(i) = theta3*180/pi;
theta22(i) =theta2*180/pi;
end
1 件のコメント
per isakson
2019 年 6 月 23 日
BTW, doc says: "Avoid assigning a value to the index variable within the loop statements."
回答 (2 件)
infinity
2019 年 6 月 23 日
Since "omega3" is a vector, which is not scalar and you calculate alpha3 by using omega3. So, I suggest you change "omge3" in
Rdot(i) = (-R2*omega2*sin(theta2))+ (R3*omega3*cos(theta3));
%acceleration
alpha3 (i) = ((-omega2.^2)*R2*sin(theta2)+ (omega3.^2)*R3*sin(theta3))/R3*cos(theta3);
by
omega3(i)
If this is not your formula, you should check it again.
0 件のコメント
per isakson
2019 年 6 月 23 日
編集済み: per isakson
2019 年 6 月 23 日
One thing is to make a code run without throwing errors, another is to make it produce the intended result.
Replacing omega3 by omega3(i) and alpha3 by alpha3(i) in the right hand side of the lines, which throw errors, makes the code run.
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!