【问题标题】:Double integration using experimental data使用实验数据进行双重积分
【发布时间】:2015-09-03 21:00:32
【问题描述】:

我需要使用实验数据执行双重积分,但我的积分限制对于每个积分都是相同的,在这种情况下是时间。数学上我需要计算:

E [ a0+ ∫0T a(t)dt ] = a + limTx → ∞ sub> (1/T) ∫0T0t a dt dT

经过一番搜索,我到达了:

T = 0:0.1:600;
x = T;
A = rand(1,length(T)); % my data
pp_int = spline(T,A );
DoubleIntegration = integral(@(x)arrayfun(@(T )(integral(@(T ) ppval(pp_int,T ),0,  T  )),x),0,T(end)  );

代码需要很长时间才能运行并提供巨大的价值。我认为我的问题是 Matlab 可能无法处理样条曲线,但我不知道如何解决。

【问题讨论】:

  • 有一个integral2函数可能会更有效。此外,考虑到您输入的数据,您的预期值约为 180,000(rand 在 0 和 1 之间是统一的,因此所有值都是正数。
  • 我认为使用integral2函数虽然该函数需要两个变量的依赖关系,但我不知道如何使用样条线执行此步骤。我的真实数据有正值和负值,rand 函数只是为了提供更多信息。

标签: matlab integration splines


【解决方案1】:

首先,你不应该在一堆东西上使用同一个字母;您的代码很难阅读,因为必须弄清楚 T 在每个实例中的含义。

第二,纯数学有帮助:经过变量的改变和简单的计算,双积分变成了单积分:

0T0x a(t) dt dx = ∫0TtT a(t) dx dt = ∫0T sup> (Tt)*a(t) dt

我使用了较小范围内的非随机数据进行演示:

T = 0:0.1:60;
x = T;
A = sin(T.^2); % my data
pp_int = spline(T,A );
tic
DoubleIntegration = integral(@(x) arrayfun(@(T )(integral(@(T ) ppval(pp_int,T ),0,  T  )),x),0,T(end)  );
toc
tic
SingleIntegration = integral(@(t) (T(end)-t).*ppval(pp_int,t), 0, T(end));
toc
disp(DoubleIntegration)
disp(SingleIntegration)

输出:

Elapsed time is 27.751744 seconds.
Elapsed time is 0.007223 seconds.
   51.3593

   51.3593

同样的结果,快了 3800 倍。

【讨论】:

    猜你喜欢
    • 2012-05-07
    • 1970-01-01
    • 2016-12-13
    • 2016-12-13
    • 2016-05-16
    • 2014-07-27
    • 1970-01-01
    • 1970-01-01
    • 2017-04-06
    相关资源
    最近更新 更多