【问题标题】:Numeric integration for two variables and a list of parameters?两个变量和参数列表的数值积分?
【发布时间】:2016-08-14 05:22:03
【问题描述】:

在 MATLAB 文档中,他们有一个使用一个参数 c 对单个变量进行数值积分的示例:

fun = @(x,c) 1./(x.^3-2*x-c);
q = integral(@(x)fun(x,5),0,2)

如果我想对两个变量和两个参数进行数值积分怎么办?

【问题讨论】:

    标签: matlab integration numerical-methods calculus numerical-integration


    【解决方案1】:

    如果你想对两个变量进行积分,你需要使用integral2

    一个有两个变量的例子:

    fun = @(x,y) 1./( sqrt(x + y) .* (1 + x + y).^2 );
    ymax = @(x) 1 - x;
    q = integral2(fun,0,1,0,ymax)
    
    q =
        0.2854
    

    如果你想要几个参数,而两个变量呢:

    fun = @(x,y,c,d) c./(sqrt(x + d*y) .* (1 + x + y).^2);
    ymax = @(x) 1 - x;
    q = integral2(@(x,y) fun(x,y,3,4),0,1,0,ymax)
    
    q =
    0.5708
    

    或者简单地说:

    c = 3; d = 4;
    fun = @(x,y) c./( sqrt(x + d*y) .* (1 + x + y).^2 )
    ymax = @(x) 1 - x;
    q = integral2(fun,0,1,0,ymax)
    
    q = 
        0.5708
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-05
      • 2015-12-22
      • 2016-11-08
      • 2018-12-24
      • 1970-01-01
      • 2014-02-12
      • 2015-05-05
      • 1970-01-01
      相关资源
      最近更新 更多