• 1402/03/10

چرا برای منحنی را نشون نمیده؟ :

سلام استاد

عرض ادب

چرا برای منحنی را نشون نمیده؟

لطفا راهنمايي بفرماييد.

اين كدي هست كه زده ام:

close all;
clear;
clc;
axis([0 70 0 70])
hold on
button=1;i=1;
while(button==1)
    [x,y,button]=ginput(1);
    plot(x,y,'bo');
    listx=x;
    listy=y;
    i=i+1;
end
c=polyfit(listx,listy,length(listx)-1);
xlist=listx(1):0.1:listx(end);
poly_values=polyval(c,xlist);
plot(xlist,poly_values,'b:',listx,listy,'ro')
L1=40;L2=30;
for i=1:length(xlist)
    x=xlist(i);
    y=poly_values(i);
    c2=(x^2 + y^2 - L1^2 - L2^2)/(2*L1*L2);
    if abs(c2)>1
        disp("error");
    end
    s2=sqrt(1-c2^2);
    theta2=atan2d(s2,c2);
    theta1=atan2d(y,x)-atan2d(L2*s2,L1+L2*c2);
    mid_x=L1*cosd(theta1);
    mid_y=L1*sind(theta1);
    arms_x=[0 mid_x x];
    arms_y=[0 mid_y y];
    hold off
    plot(arms_x,arms_y,'g',arms_x,arms_y,'go',xlist,poly_values,'b:',listx,listy,'bo');
    axis([0 70 0 70]);
    hold on
    pause(0.0001);
end
logo-samandehi