算了一下,发现有奇异性出现,这个可能是模型的问题,而非程序的问题.
你自己再仔细检查一下. 以下是我的代码:
%%%%%%%%%%%%%%%%%%
function y=mydffun()
clear
global c r
format long
dmin=0.0;
dmax=5;
qmin=0.0;
qmax=5;
c=[0.1;0.3;0.2];
n=0;
r=10;
while n<1000 & r>1e-6
f1=dblquad(@ff1,dmin,dmax,qmin,qmax)-1;
f2=dblquad(@ff2,dmin,dmax,qmin,qmax)-1;
f3=dblquad(@ff3,dmin,dmax,qmin,qmax)-32;
f=[f1;f2;f3];
ja(1,1)=dblquad(@dff1,dmin,dmax,qmin,qmax);
ja(1,2)=dblquad(@dff2,dmin,dmax,qmin,qmax);
ja(1,3)=dblquad(@dff3,dmin,dmax,qmin,qmax);
ja(2,1)=dblquad(@dff4,dmin,dmax,qmin,qmax);
ja(2,2)=dblquad(@dff5,dmin,dmax,qmin,qmax);
ja(2,3)=dblquad(@dff6,dmin,dmax,qmin,qmax);
ja(3,1)=dblquad(@dff7,dmin,dmax,qmin,qmax);
ja(3,2)=dblquad(@dff8,dmin,dmax,qmin,qmax);
ja(3,3)=dblquad(@dff9,dmin,dmax,qmin,qmax);
ja;
condition=cond(ja);
n=n+1;
nc=c-inv(ja)*f;
ef=[abs((nc(1)-c(1))/c(1));abs((nc(2)-c(2))/c(2));abs((nc(3)-c(3))/c(3))];
r=max(ef);
c=nc;
end
y=c
%%%%%%%%%%%%%%%%%%%%
function y=dff1(d,v)
global c r
format long
y=-exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%
function y=dff2(d,v)
global c r
format long
y=-d.^3.*exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=dff3(d,v)
global c r
format long
y=-d.^3.*v.^2.*exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%
function y=dff4(d,v)
global c r
format long
y=-d.^3.*exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%
function y=dff5(d,v)
global c r
format long
y=-d.^6.*exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=dff6(d,v)
global c r
format long
y=-d.^6.*v.^2.*exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=dff7(d,v)
global c r
format long
y=-d.^3.*v.^2.*exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=dff8(d,v)
global c r
format long
y=-d.^6.*v.^2.*exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=dff9(d,v)
global c r
format long
y=-d.^6.*v.^4.*exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=ff1(d,v)
global c r
format long
y=exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=ff2(d,v)
global c r
format long
y=d.^3.*exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%%
function y=ff3(d,v)
global c r
format long
y=d.^3.*v.^2.*exp(-c(1)-c(2).*d.^3-c(3).*d.^3.*v.^2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |