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

26 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Chunru
Chunru el 9 de Ag. de 2021
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 comentarios
Chunru
Chunru el 10 de Ag. de 2021
% 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by