声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2195|回复: 6

[编程技巧] MATLAB里怎么没有函数quad2ddgen

[复制链接]
发表于 2013-5-5 20:19 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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

本帖被以下淘专辑推荐:

回复
分享到:

使用道具 举报

发表于 2013-5-6 13:55 | 显示全部楼层
 楼主| 发表于 2013-5-6 14:46 | 显示全部楼层

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.

>>

期待你的回复
发表于 2013-5-6 14:54 | 显示全部楼层
般若沁 发表于 2013-5-6 14:46
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
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);
     while  t2(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{:});
发表于 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
不是同一帖就有了?

Ref:

Thanks a lot!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-12-26 04:18 , Processed in 0.075080 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表