Query data is in MESHGRID format, NDGRID format will yield better performance

8 vues (au cours des 30 derniers jours)
Msimon q
Msimon q le 10 Fév 2022
Commenté : Rik le 10 Fév 2022
I would like to take double integral from descrete data (I don't want to use trapz) with integral2.
I did the following code but i get warning that:Query data is in MESHGRID format, NDGRID format will yield better performance.
It suggested to transpose like np=np' and nt=nt' but i get the warning again. Since it is in a for loop, this warning itself slows down my run a lot. what is wrong with my approach? I used all alternatives with phi, phi' ....
also i tried pagetranspose function but did not work...
Appreciate to tell me what is fastest approach if i want to integrate my data with Integral2, where theta, phi and p is given.
theta = linspace(0,pi,nTheta);
phi = linspace(0,2*pi,nPhi);
p=zeros(nPhi,nTheta);
[np,nt]=ndgrid(phi,theta);
f1 = griddedInterpolant(np,nt,p);
f2= @(np,nt) f1(np,nt);
integral2(f2,0,2*pi,0,pi)
  1 commentaire
Rik
Rik le 10 Fév 2022
If it is the warning itself that slows down the process, you can turn it off (have a look at lastwarn to determine the warning ID).

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by