我的.m函数如下:function F = myfun(x)F = [(2*x(1)+3*x(2)+x(3))^2*(x
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/13 16:04:06
我的.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.
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.
function函数的输入值应该是个1*3的矩阵,但你的输入变量是1*2的,超出范围了
再问: 我改了,还是不行啊。具体指点下行么?
再答: 第二个问题是你的矩阵第二行式子写错了,多了个右括号
再问: 我改了,还是不行啊。具体指点下行么?
再答: 第二个问题是你的矩阵第二行式子写错了,多了个右括号
matlab中如何用function建立一个y=f(x)函数?直接function y=f(x) y=x.^2+3*x+
the function f given by f(x)=9*x^(2/3)+3x-6 has a relative m
matlab中,怎样用function定义带参数的方程? 比如 function y=myfun(x) y=x(1)+x
已知函数f(x)满足2f(x)+f(1/x)=3x,求f(x)的解析式
已知F(X)满足2F(X)+F(1/X)=3/X,求函数F(X)的表达式
find the inverse of the function:f(x)= (4x-1)/(2x+3)
设函数f(x)=x²-1,对任意x∈[3/2,+∞),f(x/m)-4m²f(x)≤f(x-1)+4
设函数f(x)对所有非零实数x,有f(x)+2f(1/x)=3x,求方程f(x)=f(-x)的
函数数学题.如下.已知f(x)满足2f(x)+f(1/x)=3x ,求f(x).急用,
定义F(x)=max[f(x),g(x)],已知函数f(x)=x^2-x-3,g(x)=x+5,求F(x)的最大值
函数f(x)={(1/2)^x,(x>4),f(x+3),(x
已知f(x-1)=x^2-3x,则函数f(x)的解析式