Query data is in MESHGRID format, NDGRID format will yield better performance
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
Rik
2022-2-10
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).
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!