Azzera filtri
Azzera filtri

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​>validateC​entersAndR​adii (line 283) validateat​tributes(c​enters,{'n​umeric'},{​'nonsparse​','real', ... Erro

3 visualizzazioni (ultimi 30 giorni)
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 Commenti
dpb
dpb il 4 Dic 2019
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...

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 5 Dic 2019
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

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by