How to integrate 3-dimensional numerical array into one dimension using Parallel Computing Toolbox?

14 次查看(过去 30 天)
I have a 3-dimensional array X to be numerically integrated with trapz function. The size of array is
size(X) = p,q,r
and the third dimension (size r) is to be integrated with an integral variable given by a vactor vx whose length is r. The result Y will be 2-dimensional matrix as
size(Y) = p,q
Then, how to calculate this numerical integration using GPU with Parallel Computing Toolbox?
Thank you.

采纳的回答

Chunru
Chunru 2021-8-9
Xd= distributed(X, 3) % distributed along 3rd dim
Y = trapz(Xd, 3); % trapz support parallel processing for distributed input array
It might be better to use the 1st dimension as the integration dimension.
  3 个评论
Chunru
Chunru 2021-8-10
% Try the following along the 1st dim
% The syntax with dim is for the so-called 'Composite array', see doc
% distributed
xd = distributed(rand(20,8,6));
y = squeeze(trapz(xd))
y = 8.2293 9.7236 8.1337 7.3964 8.8491 8.7905 11.4429 8.1487 10.3092 7.6098 9.9407 9.9593 8.4093 9.6940 9.1529 8.2184 8.9330 10.8494 11.1636 10.2440 9.0015 9.0076 11.0077 9.1387 10.8180 8.4163 11.0037 9.4596 10.3310 11.7726 9.3094 10.5408 8.0568 10.5597 8.5339 10.8676 12.5096 8.2943 11.0609 9.3801 9.5628 9.5251 8.4620 11.0499 8.9461 8.4494 10.8111 10.9607

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by