我的.m函数如下:function F = myfun(x)F = [(2*x(1)+3*x(2)+x(3))^2*(x(1)+x(2))*(1-x(3))/((1-x(1)-x(2))*(2-0.5*x(1))^0.5*(1+3+1.5*x(1)+2*x(2))^1.5)-3.46e+11;(2*x(1)+3*x(2)+x(3))^3*(x(1)+x(2))*(1-x(3))/((1-x(1)-x(2))*(1-x(2)-x(3))^0.5*(1+3+1.5*x(1
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 09:25:29
我的.m函数如下:function F = myfun(x)F = [(2*x(1)+3*x(2)+x(3))^2*(x(1)+x(2))*(1-x(3))/((1-x(1)-x(2))*(2-0.5*x(1))^0.5*(1+3+1.5*x(1)+2*x(2))^1.5)-3.46e+11;(2*x(1)+3*x(2)+x(3))^3*(x(1)+x(2))*(1-x(3))/((1-x(1)-x(2))*(1-x(2)-x(3))^0.5*(1+3+1.5*x(1
我的.m函数如下:
function F = myfun(x)
F = [(2*x(1)+3*x(2)+x(3))^2*(x(1)+x(2))*(1-x(3))/((1-x(1)-x(2))*(2-0.5*x(1))^0.5*(1+3+1.5*x(1)+2*x(2))^1.5)-3.46e+11;
(2*x(1)+3*x(2)+x(3))^3*(x(1)+x(2))*(1-x(3))/((1-x(1)-x(2))*(1-x(2)-x(3))^0.5*(1+3+1.5*x(1)+2*x(2))^2)-0.966;
(2*x(1)+3*x(2)+x(3))*(x(1)+x(2))*x(3)/((x(1)+x(2))*(1-x(3))*(1-x(2)-x(3))) -1.176];
end
运行程序如下:
>> x0 = [-23 23]; % Make a starting guess at the solution
options=optimset('Display','iter'); % Option to display output
[x,fval] = fsolve(@myfun,x0,options) % Call solver
出错信息:
Attempted to access x(3); index out of bounds because numel(x)=2.
Error in ==> myfun at 2
F = [(2*x(1)+3*x(2)+x(3))^2*(x(1)+x(2))*(1-x(3))/((1-x(1)-x(2))*(2-0.5*x(1))^0.5*(1+3+1.5*x(1)+2*x(2))^1.5)-3.46e+11;
Error in ==> fsolve at 248
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation.FSOLVE cannot continue.
我的.m函数如下:function F = myfun(x)F = [(2*x(1)+3*x(2)+x(3))^2*(x(1)+x(2))*(1-x(3))/((1-x(1)-x(2))*(2-0.5*x(1))^0.5*(1+3+1.5*x(1)+2*x(2))^1.5)-3.46e+11;(2*x(1)+3*x(2)+x(3))^3*(x(1)+x(2))*(1-x(3))/((1-x(1)-x(2))*(1-x(2)-x(3))^0.5*(1+3+1.5*x(1
function函数的输入值应该是个1*3的矩阵,但你的输入变量是1*2的,超出范围了