zhouhao163
2009-06-18, 20:01
原方程组见附件。
当方程个数为三时,编程如下:
函数的M文件为:
function En=fentropy(u)
c=u;
En=zeros(3,1);
syms x;
En(1)=int(exp(c(1)+c(2)*x+c(3)*x^2),'x',0,1)-1;
En(2)=int(x*exp(c(1)+c(2)*x+c(3)*x^2),'x',0,1)-0.87791;
En(3)=int(x^2*exp(c(1)+c(2)*x+c(3)*x^2),'x',0,1)-0.77161;
调用程序如下:
clear,clc;
u=10*ones(3,1);
c=fsolve(@fentropy,u)
不到两分钟可以解出c=[-433.1652; 992.7220; -565.3877]
当方程个数为四时,编程如下:
函数的M文件为:
function En=fentropy(u)
c=u;
En=zeros(4,1);
syms x;
En(1)=int(exp(c(1)+c(2)*x+c(3)*x^2+c(4)*x^3),'x',0,1)-1;
En(2)=int(x*exp(c(1)+c(2)*x+c(3)*x^2+c(4)*x^3),'x',0,1)-0.87791;
En(3)=int(x^2*exp(c(1)+c(2)*x+c(3)*x^2+c(4)*x^3),'x',0,1)-0.77161;
En(4)=int(x^3*exp(c(1)+c(2)*x+c(3)*x^2+c(4)*x^3),'x',0,1)-0.67894;
调用程序如下:
clear,clc;
u=10*ones(4,1);
c=fsolve(@fentropy,u)
运行二十分钟后出错:
??? The following error occurred converting from sym to
double:
Error using ==> sym.double at 25
DOUBLE cannot convert the input expression into a double
array.
If the input expression contains a symbolic variable, use the
VPA function instead.
Error in ==> fentropy at 5
En(1)=int(exp(c(1)+c(2)*x+c(3)*x^2+c(4)*x^3),'x',0,1)-1;
Error in ==> trustnleqn at 225
F = feval(funfcn{3},x,varargin{:});
Error in ==> fsolve at 297
[x,FVAL,JACOB,EXITFLAG,OUTPUT,msg]=...
Error in ==> maxentropy at 3
c=fsolve(@fentropy,u)
请教各路武林高手,带积分(积分后没有确定表达式)的方程组求解,
有没有更好的编程方法?当方程增至五、六时,计算量非常大,如何处理?
望赐教!!!
当方程个数为三时,编程如下:
函数的M文件为:
function En=fentropy(u)
c=u;
En=zeros(3,1);
syms x;
En(1)=int(exp(c(1)+c(2)*x+c(3)*x^2),'x',0,1)-1;
En(2)=int(x*exp(c(1)+c(2)*x+c(3)*x^2),'x',0,1)-0.87791;
En(3)=int(x^2*exp(c(1)+c(2)*x+c(3)*x^2),'x',0,1)-0.77161;
调用程序如下:
clear,clc;
u=10*ones(3,1);
c=fsolve(@fentropy,u)
不到两分钟可以解出c=[-433.1652; 992.7220; -565.3877]
当方程个数为四时,编程如下:
函数的M文件为:
function En=fentropy(u)
c=u;
En=zeros(4,1);
syms x;
En(1)=int(exp(c(1)+c(2)*x+c(3)*x^2+c(4)*x^3),'x',0,1)-1;
En(2)=int(x*exp(c(1)+c(2)*x+c(3)*x^2+c(4)*x^3),'x',0,1)-0.87791;
En(3)=int(x^2*exp(c(1)+c(2)*x+c(3)*x^2+c(4)*x^3),'x',0,1)-0.77161;
En(4)=int(x^3*exp(c(1)+c(2)*x+c(3)*x^2+c(4)*x^3),'x',0,1)-0.67894;
调用程序如下:
clear,clc;
u=10*ones(4,1);
c=fsolve(@fentropy,u)
运行二十分钟后出错:
??? The following error occurred converting from sym to
double:
Error using ==> sym.double at 25
DOUBLE cannot convert the input expression into a double
array.
If the input expression contains a symbolic variable, use the
VPA function instead.
Error in ==> fentropy at 5
En(1)=int(exp(c(1)+c(2)*x+c(3)*x^2+c(4)*x^3),'x',0,1)-1;
Error in ==> trustnleqn at 225
F = feval(funfcn{3},x,varargin{:});
Error in ==> fsolve at 297
[x,FVAL,JACOB,EXITFLAG,OUTPUT,msg]=...
Error in ==> maxentropy at 3
c=fsolve(@fentropy,u)
请教各路武林高手,带积分(积分后没有确定表达式)的方程组求解,
有没有更好的编程方法?当方程增至五、六时,计算量非常大,如何处理?
望赐教!!!