第二个例子好像不太对,运行不出来结果
另外,我想知道能不能把fun函数或者myfun文件,与命令窗口的命令代码,都写在一个文件中。
例如第二个例子:
function F=myfun()
F=[x(1)-3*x(2)-sin(x(1)); 2*x(1)+x(2)-cos(x(2))];
%%command windows
% It still has some problems
% x0=[0;0]; % 设定初始值
% options=optimset('Display','iter'); % 设定优化条件
% [x,fv]=fsolve(@myfun,x0,options) % 优化求解