Query data is in MESHGRID format, NDGRID format will yield better performance
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Rik
el 10 de Feb. de 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).
Respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!