This error keeps popping up and I have no idea why: Error using viscircles Expected input number 1, centers, to be real. Error in viscircles>validateCentersAndRadii (line 283) validateattributes(centers,{'numeric'},{'nonsparse','real', ... Erro
조회 수: 1 (최근 30일)
이전 댓글 표시
I am trying to do an animation for a linkage system and it is not plotting one of the links for some reason.
P1_pos = [56.25;43.1];
P2_pos = [56.25-A*cos(theta);43.1-A*sin(theta)];
P4_pos = C*[0;1];
P5_pos = D*[0*sin(theta);-1+1*sin(theta)]; %P5_pos = D*[0;-1+sin(theta)];
E = sqrt(A^2 + D^2 - 2*A*D*cos(theta));
a = asin(A*sin(theta)./E);
b = acos(E.^2 + C^2 - B^2)./(2*E*C);
P3_pos = [C + B*cos(a+b); B*sin(a+b)];
P5x = P5_pos(1,:);
P5y = P5_pos(:,1);
P5vx = diff(P5x);
P5vy = diff(P5y);
P5v = sqrt(P5vx.^2 + P5vy.^2);
ani = subplot(2,1,1);
P1_pos_cir = viscircles(P1_pos',0.05);
P2_pos_cir = viscircles(P2_pos(:,i)',0.05);
P3_pos_cir = viscircles(P3_pos(:,i)',0.05);
P4_pos_cir = viscircles(P4_pos',0.05);
P5_pos_cir = viscircles(P5_pos(:,i)',0.05);
댓글 수: 6
dpb
2019년 12월 4일
Yeah, I noticed that too, but that's using i as an array index which would be another error on indexing must be real and positive...
채택된 답변
Walter Roberson
2019년 12월 5일
You did not give us any values to test with for A, B, C, D
E = sqrt(A^2 + D^2 - 2*A*D*cos(theta));
Looks like the area of a triangle with sides A and D and angle theta between them. The area of a triangle is often greater than 1 but depending on the values of the variables could also be small < 1.
a = asin(A*sin(theta)./E);
A*sin(theta)./E can end up greater than 1, leading to asin() of a value greater than 1, which is complex valued. Everything gets messy from that point
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!