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!