How to plot a data in spherical coordinates?
135 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Jagadeesh Korukonda
il 16 Ago 2022
Commentato: Jagadeesh Korukonda
il 17 Ago 2022
Let me explain, what I'm actually solving.
I'm solving Diffusion-Reaction equation(2D) in spherical coordinates(axis-symmetric case).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1099730/image.png)
I'm solving this equation numerically. So at the end I'm getting
, r, θ.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1099735/image.png)
So I want to plot this function
in r and θ plane instead of
palne
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1099735/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1099740/image.png)
I'm attaching data.mat file to this question
Can anyone help in this regard?
Thanks in advance.
0 Commenti
Risposta accettata
David Hill
il 16 Ago 2022
[x,y,z]=sph2cart(th,conc,r);
surf(x,y,z);
3 Commenti
Torsten
il 16 Ago 2022
Modificato: Torsten
il 16 Ago 2022
If you solve the equation in r and theta, you also get the solution C in r and theta. So plotting in the r-theta plane would simply mean
[R,THETA] = ndgrid(r,theta);
surf(R,THETA,C)
where C(i,j) = C(r(i),theta(j)).
So you plot over a rectangle with x-axis r and y-axis theta (0<=r<=R, 0<=theta<=2*pi).
If you want to plot in the x-y-plane (thus over the circle with radius R), you must convert to x and y coordinates via x = r*cos(theta), y= r*sin(theta).
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!