看板 MATLAB 關於我們 聯絡資訊
時間 t =0:0.2:10 想求解以下的x 如: F=[x(1)-0.5.*cos(x(3)) x(2)-0.5.*sin(x(3)) x(4)+0.5.*cos(x(6))-1; x(5)+0.5.*sin(x(6))-1+0.1*t; x(1)+0.5*cos(x(3))-1+0.5*cos(x(6)); x(2)+0.5*cos(x(3))-1+0.1*t+0.5*cos(x(6))]; ----------------------------------------------------------------------------------------- 原本將funcion打在m-file中 function F = myfunc(x,t) F=[x(1)-0.5*cos(x(3)) x(2)-0.5*sin(x(3)) x(4)+0.5*cos(x(6))-1; x(5)+0.5*sin(x(6))-1+0.1*t; x(1)+0.5*cos(x(3))-1+0.5*cos(x(6)); x(2)+0.5*cos(x(3))-1+0.1*t+0.5*cos(x(6))]; 接著在命令視窗中以 for 迴圈寫 for t=0:0.2:10 x0=[0.5;0;0;1;0.5;pi/2]; q1=fsolve(@myfunc,x0); end 但出現了以下 ??? Input argument "t" is undefined. 我該如何去修改並完成? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.124.33.120
Raymond0710:你的t宣告global 把myfunc(x,t)改myfunc(x) 11/10 22:36
Raymond0710:funtion裡面也要加一行 global t 11/10 22:40