【问题标题】:How to perform indefinite integration of this function in MATLAB?如何在 MATLAB 中执行此函数的无限积分?
【发布时间】:2016-12-18 14:30:22
【问题描述】:

如图所示,我需要执行以下操作。我需要使用 MATLAB 计算不同输入(x)的函数 H 的值。

我从 Symbolic Math Toolbox 给出以下命令

syms y t x;
f1=(1-exp(-y))/y;
f2=-t+3*int(f1,[0,t]);
f3=exp(f2);
H=int(f3,[0,x]);

但无法计算第二个积分的值,即函数 H 中的积分,我的输出格式为

H =

int(exp(3*eulergamma - t - 3*ei(-t) + 3*log(t)), t, 0, x)

如果你们中的任何人知道如何评估这个或对此有不同的想法,请与我分享。

【问题讨论】:

  • 我已经按照您的命令执行了,但我无法获得所需的输出。事实上,我得到的输出与未解决的最后一步相同。

标签: matlab integral indefinite


【解决方案1】:

使用integral直接求数值解:

由于您要针对x的不同值计算H,因此可以使用数值解代替解析解。

代码:

syms y t;
f1=(1-exp(-y))/y;   f2=-t+3*int(f1,[0,t]);  f3=exp(f2);
H=integral(matlabFunction(f3),0,100)   % Result of integration when x=100 

输出:

H =
   37.9044

使用 Monte-Carlo 积分找到近似解析解:

它可能是一个“Elliptic Integral”,不能用elementary functions 表示。但是,您可以使用“Monte-Carlo Integration”找到近似解析解:


其中 f(c) = 1/n Σ f(xᵢ)

代码:

syms x y t;

f1=(1-exp(-y))/y;   f2=-t+3*int(f1,[0,t]);  f3=exp(f2);
f3a= matlabFunction(f3);       % Converting to function handle

n = 1000;      
t = x*rand(n,1);               % Generating random numbers within the limits (0,x)
MCint(x) = x * mean(f3a(t));   % Integration
H= double(MCint(100))          % Result of integration when x=100  

输出:

H =
   35.2900

% Output will be different each time you execute it since it is based
% on generation of random numbers

这种方法的缺点:

  1. 解决方案并不精确,而是近似的。
  2. n 的值越大,结果越好,代码执行速度越慢。

阅读matlabFunction、integral、Random Numbers Within a Specific Range、mean和double的文档以进一步了解代码。

【讨论】:

  • 谢谢先生。你的建议完全奏效。但正如我之前应该提到的,我希望函数 H 的值在我希望 H 成为不定解的随机点进行评估。到底有没有可能?
  • 你写的问题不是不定积分。阅读this简单解释
猜你喜欢
  • 2015-08-19
  • 2011-03-07
  • 2016-05-20
  • 1970-01-01
  • 2016-09-05
  • 2015-12-10
  • 1970-01-01
  • 1970-01-01
  • 2015-07-23
相关资源
最近更新 更多