Effacer les filtres
Effacer les filtres

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

14 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Chunru
Chunru le 9 Août 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 commentaires
Chunru
Chunru le 10 Août 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
Daiki
Daiki le 10 Août 2021
@Chunru Thank you. It was enough to delete the argument of dimension.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by