使用 fsolve 具體如下執行主檔案,程式碼如下x0 = [0.01;0.01;0.01]; % Make a starting guess at the solutionoptions=optimset("Display","iter"); % Option to display output[x,fval] = fsolve(@myfsolvefun,x0,options); % Call optimizex 然後新建個m檔案 命名為myfsolvefun.m(即定義這個函式)myfsolvefun.m裡的程式碼如下function F = myfsolvefun(sita)x=2;y=3;z=4;l0=5;l1=6;l2=7;l3=8; %這裡我隨便賦的值,根據你自己的要求修改F=[cos(sita(1))*(l1*sin(sita(2))+l2*sin(sita(2)+sita(3))+l3)-x;... sin(sita(1))*(l1*sin(sita(2))+l2*sin(sita(2)+sita(3))+l3)-y;... l0+l1*cos(sita(2))+l2*cos(sita(2)+sita(3))-z];最後X為輸出結果
使用 fsolve 具體如下執行主檔案,程式碼如下x0 = [0.01;0.01;0.01]; % Make a starting guess at the solutionoptions=optimset("Display","iter"); % Option to display output[x,fval] = fsolve(@myfsolvefun,x0,options); % Call optimizex 然後新建個m檔案 命名為myfsolvefun.m(即定義這個函式)myfsolvefun.m裡的程式碼如下function F = myfsolvefun(sita)x=2;y=3;z=4;l0=5;l1=6;l2=7;l3=8; %這裡我隨便賦的值,根據你自己的要求修改F=[cos(sita(1))*(l1*sin(sita(2))+l2*sin(sita(2)+sita(3))+l3)-x;... sin(sita(1))*(l1*sin(sita(2))+l2*sin(sita(2)+sita(3))+l3)-y;... l0+l1*cos(sita(2))+l2*cos(sita(2)+sita(3))-z];最後X為輸出結果