Query data is in MESHGRID format, NDGRID format will yield better performance
8 views (last 30 days)
Show older comments
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 Comment
Rik
on 10 Feb 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).
Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!