般若沁 发表于 2013-5-5 20:19

MATLAB里怎么没有函数quad2ddgen

在计算任意区域二重积分,遇到quad2ddgen函数可以解决,但是help quad2ddgen,不存在该内置函数的,各位大侠,求解。多谢。

ChaChing 发表于 2013-5-6 13:55

quad2ddgen並非matlab built-in function
http://www.mathworks.com/matlabcentral/newsreader/view_thread/79652
http://read.pudn.com/downloads15/sourcecode/math/58735/nit/quad2dggen.m__.htm

般若沁 发表于 2013-5-6 14:46

ChaChing 发表于 2013-5-6 13:55 static/image/common/back.gif
quad2ddgen並非matlab built-in function
http://www.mathworks.com/matlabcentral/newsreader/view_threa ...

Thanks for your suggestion!

关于这个quad2ddgen,在matlab7里运行的代码出现错误:

??? function int = quad2dgg(fun,xlow,xhigh,ylow,yhigh,tol,varargin)
    |
Error: Function definitions are not permitted at the prompt or in scripts.

>>

期待你的回复

ChaChing 发表于 2013-5-6 14:54

般若沁 发表于 2013-5-6 14:46 static/image/common/back.gif
Thanks for your suggestion!

关于这个quad2ddgen,在matlab7里运行的代码出现错误:


Ref:
2.常见的程序出错问题整理 http://www.chinavib.com/thread-46001-1-1.html
   7F->Function definitions are not permitted at the prompt or in scripts
From http://home.chinavib.com/blog-63979-18250.html

般若沁 发表于 2013-5-6 15:34

ChaChing 发表于 2013-5-6 14:54 static/image/common/back.gif
Ref:
2.常见的程序出错问题整理 http://www.chinavib.com/thread-46001-1-1.html
   7F->Function def ...

老师好,解决一个问题,又一个问题了:
df=0.1;xf=0.2;w=5;p=8;v=1;c=1.5;%缺货惩罚因子,成本弥补因子,收购价格,残值,单位成本%
syms x y g
for j=1:1:10;
    eta(j)=j*0.1;%风险系数%
    A(j)=0;
    i=0.2;%积分上限%
    l(j)=norminv(eta(j)*(normcdf(1,0.8,0.2)-normcdf(0,0.8,0.2))+normcdf(0,0.8,0.2),0.8,0.2);
    fun=inline('x.*normpdf(x,0.8,0.2)/(normcdf(1,0.8,0.2)-normcdf(0,0.8,0.2))','x');
    fun1=inline('normpdf(x,0.8,0.2)/(normcdf(1,0.8,0.2)-normcdf(0,0.8,0.2))','x');
    m(j)=quadl(fun,0,l(j));
    m(j)=double(m(j));
    t(j)=quadl(fun,0,i)-(eta(j)*c-m(j))/((1+df-xf)*w);   
    while t(j)<A(j)
      i=i+0.0001;
      t(j)=quadl(fun,0,i)-(eta(j)*c-m(j))/((1+df-xf)*w);   
    end
   I(j)=i-0.0001;
   derta(j)=-w.*(1-xf).*I(j)-xf.*w.*quadl(fun,0,1)-eta(j)*c+xf.*w.*m(j)+(1+df-xf).*w.*I(j)*quadl(fun1,0,I(j));
%***x的pdf:normpdf(x,0.8,0.2)/(normcdf(1,0.8,0.2)-normcdf(0,0.8,0.2))***********y的密度函数:normpdf(y,5,2)/(normcdf(10,5,2)-normcdf(0,10,2))*******反应系数,收购成本*********%   
    Q=0.5;
    fun2=inline('x.*normpdf(x,0.8,0.2)/(normcdf(1,0.8,0.2)-normcdf(0,0.8,0.2)).*normpdf(y,5,2)/(normcdf(10,5,2)-normcdf(0,10,2))','x','y');
    yupper=inline('x.*Q','x');
    t2(j)=quad2dgg(fun2,0,yupper,0,Q./10)+quadl(fun,Q./10,1)-(p*quadl(fun,0,1)+derta(j))/(p-v);
   whilet2(j)<0
      Q=Q+0.001;
   t2(j)=quad2dgg(fun2,0,yupper,0,Q./10)+quadl(fun,Q./10,1)-(p*quadl(fun,0,1)+derta(j))/(p-v);
   end
   Qr(j)=Q-0.001;
end

这个是程序,运行出来的结果。
??? Error using ==> inlineeval
Error in inline expression ==> x.*Q
??? Error using ==> eval
Undefined function or variable 'Q'.

Error in ==> inline.feval at 34
      INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);

Error in ==> gquad2dg at 54
xhigh=feval(limxhigh,y);

Error in ==> quad2dgg at 39
int_old=gquad2dg(fun,xlow,xhigh,ylow,yhigh,2,2,varargin{:});

ChaChing 发表于 2013-5-6 15:43

Undefined function or variable
不是同一帖就有了?

Ref:
2.常见的程序出错问题整理 http://forum.vibunion.com/thread-46001-1-1.html
   3F->Undefined function or variable "a"
From http://home.vibunion.com/blog-63979-18250.html

另个人水平/时间有限, 建议先看看我给的那些连接

般若沁 发表于 2013-5-6 16:18

ChaChing 发表于 2013-5-6 15:43 static/image/common/back.gif
不是同一帖就有了?

Ref:


Thanks a lot!
页: [1]
查看完整版本: MATLAB里怎么没有函数quad2ddgen