【问题标题】:Input array size error for a quadraple integration using nested integral2 [duplicate]使用嵌套积分2的四重积分的输入数组大小错误[重复]
【发布时间】:2014-03-01 11:10:31
【问题描述】:

我需要在 matlab 中使用 integral2 函数进行四重积分。代码如下:

Rb = @(rho_1,phi_1) rho_1.*cos(phi_1);
Sb = @(rho_2,phi_2) rho_2.*cos(phi_2);
Tb = @(rho_1,phi_1,rho_2,phi_2) rho_1.*cos(phi_1)-rho_2.*cos(phi_2);
InnerIntegrand = @(rho_1,phi_1,rho_2,phi_2) Rb(rho_1,phi_1).*Sb(rho_2,phi_2).*Tb(rho_1,phi_1,rho_2,phi_2);
InnerIntegral = @(rho_1,phi_1) integral2(@(rho_2,phi_2) InnerIntegrand(rho_1,phi_1,rho_2,phi_2),0,3,0,2*pi);
II = integral2(InnerIntegral,0,3,0,2*pi);

其中InnerIntegrand (rho_1,phi_1,rho_2,phi_2) 是被积函数。 InnerIntegralrho_2phi_2 进行评估,这是从外部 integral2 调用的(对 rho_1phi_1 的集成)。

我收到一个错误:

Error using  .* 
Matrix dimensions must agree.

Error in @(rho_1,phi_1,rho_2,phi_2)Rb(rho_1,phi_1).*Sb(rho_2,phi_2).*Tb(rho_1,phi_1,rho_2,phi_2)


Error in @(rho_2,phi_2)InnerIntegrand(rho_1,phi_1,rho_2,phi_2)


Error in integral2Calc>integral2t/tensor (line 238)
        Z1 = FUN(X(VTSTIDX),Y(VTSTIDX)); NFE = NFE + 1;

错误是由于两个 integral2 调用的不同数组大小导致的吗?有什么问题?

【问题讨论】:

    标签: matlab


    【解决方案1】:

    请参阅我对此similar question 的回答。 在您的情况下,您可以使用

    integral2(@(rho_1,phi_1)arrayfun(InnerIntegral,rho_1,phi_1),0,3,0,2*pi)
    

    【讨论】:

      猜你喜欢
      • 2023-03-17
      • 2021-01-31
      • 2013-11-10
      • 2021-10-20
      • 2017-03-13
      • 2020-12-25
      • 2016-05-20
      • 2016-12-13
      • 2015-01-23
      相关资源
      最近更新 更多