Can someone help me with my code. Calculate the position (coordinates x and y) of points B C and D . Calculate the linear velocity (vx and vy) of points b c d.
조회 수: 2 (최근 30일)
이전 댓글 표시
compute Th1=th(1i)+w1*t and from 0 to 10s
r(ab)=0.3;
w(ab)=0.2;
Th1(1i)=30;
w(bc)=-0.05;
r(bc)=0.25;
Th2(1i)=-20;
r(cd)=0.25;
Th3(1i)=0;
for t=0:0.5:10
Th1=Th1(1i)+w(ab)*t;
f=fprintf('Theta1(%.2d degrees) /n', Th1,t);
disp(f)
Th2=Th2(1i)+w(bc)*t;
g=fprintf('Theta2(%.2d degrees) /n', Th2,t);
disp(g)
r(b)=[r(ab)*cosd(Th1), r(ab)*sind(Th1)];
disp(r(b));
v(b)=[-w(ab)*r(ab)*cosd(Th1), w(ab)*r(ab)*cosd(Th1)];
disp(v(b));
v(a)=v(b)-w(ab)*r(ab);
disp(v(a));
r(c)=[r(ab)*cosd(Th1)+r(bc)*cosd(Th2), r(ab)*cosd(Th2)+r(bc)*sind(Th2)];
disp(r(c));
v(c)=v(b)+[-w(bc)*r(ab)*sind(Th2), w(bc)*r(ab)*cosd(Th2)];
Dy=0.0645;
Th(3)=asind(Dy-r(cy))/(r(ab));
disp(Th(3));
w(cd)=(-w(ab)*r(ab)*cosd(Th1)-w(bc)*r(ab)*cosd(Th2))/(r(ab)*cosd(Th3));
disp(w(cd));
r(d)=r(c)+[r(cd)*cosd(Th3), r(cd)*sind(Th3)];
disp(r(d));
v(d)=v(c)+[-w(cd)*r(cd)*sind(Th3), w(cd)*r(cd)*cosd(Th3)];
disp(v(d));
end
댓글 수: 2
Mann Baidi
2023년 8월 11일
편집: Mann Baidi
2023년 11월 9일
Hi Avinash,
it would be helpful if you can add comments to the code, so that we can understand the problem statement
Walter Roberson
2023년 11월 9일
Th1(1i)=30;
The only case in which that could possibly work is if Th1 is an instance of a class that defines it own subsasgn or uses matlab.mixin.indexing.RedefinesParen class so that () indexing means something relatively arbitrary.
답변 (1개)
Walter Roberson
2023년 11월 9일
Ultimately the program cannot be run because you do not define
r_ab = 0.3;
w_ab = 0.2;
Th1_1i = 30;
w_bc = -0.05;
r_bc = 0.25;
Th2_1i = -20;
r_cd = 0.25;
Th3_1i = 0;
for t=0:0.5:10
Th1 = Th1_1i + w_ab * t;
fprintf('Theta1(%.2d degrees) \n', Th1,t);
Th2 = Th2_1i + w_bc * t;
fprintf('Theta2(%.2d degrees) \n', Th2,t);
r_b = [r_ab * cosd(Th1), r_ab * sind(Th1)];
disp(r_b);
v_b = [-w_ab * r_ab * cosd(Th1), w_ab * r_ab * cosd(Th1)];
disp(v_b);
v_a = v_b - w_ab * r_ab;
disp(v_a);
r_c = [r_ab * cosd(Th1) + r_bc * cosd(Th2), r_ab * cosd(Th2) + r_bc * sind(Th2)];
disp(r_c);
v_c = v_b + [-w_bc * r_ab * sind(Th2), w_bc * r_ab * cosd(Th2)];
Dy = 0.0645;
Th3 = asind(Dy-r_cy)/(r_ab);
disp(Th3);
w_cd = (-w_ab * r_ab * cosd(Th1) - w_bc * r_ab * cosd(Th2))/(r_ab * cosd(Th3));
disp(w_cd);
r_d = r_c + [r_cd * cosd(Th3), r_cd * sind(Th3)];
disp(r_d);
v_d = v_c + [-w_cd * r_cd * sind(Th3), w_cd * r_cd * cosd(Th3)];
disp(v_d);
end
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!