哪位高手给我看看问题出在什么地方了
function f = funzh1(a);f1 =int(x*exp(a(1)*x),x,-3,3)/m(1)*int(exp(a(1)*x),x,-3,3);
f2 =int(x^2*exp(a(2)*x^2),x,-3,3)/m(2)*int(exp(a(2)*x^2),x,-3,3)
f3 =int(x^3*exp(a(3)*x^3),x,-3,3)/m(3)*int(exp(a(3)*x^3),x,-3,3);
f = f1.^2+f2.^2+f3.^2
%%%%%%%%%%%%%%%%%%%%%%%%%
>> m =[-0.0395 0.8244 -0.0655];
>> a0 =[-1 0 0];
>> a =lsqnonlin(funzh1,a0)
??? Input argument "x" is undefined.
Error in ==> funzh1 at 2
f1 =int(x*exp(a(1)*x),x,-3,3)/m(1)*int(exp(a(1)*x),x,-3,3);
>> a =lsqnonlin(funzh1,a0)
??? Undefined function or variable 'x'.
Error in ==> funzh1 at 2
f1 =int(x*exp(a(1)*x),x,-3,3)/m(1)*int(exp(a(1)*x),x,-3,3);
请高手指教,是在不知道错在什么地方了
function f =zhfun(a)f1 = int(x*exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3)/m(1)*int(exp(a(1)*x+a(2)*x^2 +a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3);
f2 =int(x^2*exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3)/m(2)*int(exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3);
f3 =int(x^3*exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3)/m(3)*int(exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3);
f4 = int(x^4*exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3)/m(4)*int(exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3);
f5 =int(x^5*exp(a(1)*x+a(2)*x^2 +a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3)/m(5)*int(exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3);
f =f1.^2+f2.^2+f3.^2+f4.^2+f5.^2
%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> m =[-0.0395,0.8244,-0.0655,1.61858,-0.1283];
>> a0 =[-1,0,0,0,0];
>> a=lsqnonlin(zhfun,a0)
??? Input argument "x" is undefined.
Error in ==> zhfun at 2
f1 = int(x*exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3)/m(1)*int(exp(a(1)*x+a(2)*x^2 +a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3);
>> a =lsqnonlin(zhfun,a0)
??? Undefined function or variable 'x'.
Error in ==> zhfun at 2
f1 = int(x*exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3)/m(1)*int(exp(a(1)*x+a(2)*x^2 +a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3);
>> syms x
>> a =lsqnonlin(zhfun,a0)
??? Undefined function or variable 'x'.
Error in ==> zhfun at 2
f1 = int(x*exp(a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3)/m(1)*int(exp(a(1)*x+a(2)*x^2 +a(3)*x^3+a(4)*x^4+a(5)*x^5),x,-3,3);
>> 不是跟你说"x" is undefined了?
函数中x,m是什么东西, 都没定义阿!
还有基本上两帖有点类似!? 是否使用编辑即可!
matlab中的高斯牛顿法,怎么用?
我有一个非线性方程组,用fsolve求解时总是显示错误,好像是说要用高斯牛顿法求解,可是我不知道怎么用的,由于本人不懂英语,所以看帮助根本看不了,请高人指点,程序错误时这么写的:Warning: Default trust-region dogleg method of FSOLVE cannothandle non-square systems; switching to Gauss-Newton method.
> In fsolve at 232
Conditioning of Gradient Poor - Switching To LM method
Optimization terminated: directional derivative along
search direction less than TolFun and infinity-norm of
gradient less than 10*(TolFun+TolX).
matlab积分问题
“x*exp(ax+bx2+cx3)在特定区间内的积分怎么求啊,应该用哪个函数,我试过fsolve /cumtrapz/trapz都出错,怎么办啊,其中x2表示x 的平方,x3为立方请高手指点下 原帖由 2008057 于 2010-2-27 19:57 发表 http://www.chinavib.com/forum/images/common/back.gif“x*exp(ax+bx2+cx3)在特定区间内的积分怎么求啊,应该用哪个函数,我试过fsolve /cumtrapz/trapz都出错,怎么办啊,其中x2表示x 的平方,x3为立方请高手指点下
int(x*exp(a*x+b*x^2+c*x^3),0,100)
%内积分
谢谢,可是还有错误
谢谢回复,这个试过了,总是显示如下错误,不知道什么原因>> syms a b c x
>> int(x*exp(a*x+b*x^2+c*x^3),-0.1,0.1)
Warning: Explicit integral could not be found.
> In sym.int at 58
ans =
int(x*exp(a*x+b*x^2+c*x^3),x = -1/10 .. 1/10) 找一本matlab数学实验相关的书籍,上面应该有详细的介绍:@)
回复 板凳 ChaChing 的帖子
这个不只是x未定义的问题,定义之后还是有错误,下一个错误提示能帮我分析下吗,好像是M文件的第二行有错,是不是表达式不对呀,还是用的函数有错误
页:
[1]