3D spherical histogram
Mostrar comentarios más antiguos
I have a collection of lines of unit length in space that have some orientation. From this I can calculate theta, phi using cart2sph.[THETA,PHI,R] = cart2sph(X,Y,Z) R would be unit, and of not much relevance here. Now I want a histogram matrix (N) using [theta phi]. In the end using N, theta, phi, I would like to plot a spherical histogram which is an extension of 2d polar command in matlab (which is polar(theta,rho)).
Regards Abhi...
5 comentarios
Walter Roberson
el 8 de Ag. de 2011
Could you point us to an example of a spherical histogram similar to what you would like to produce?
Image Analyst
el 8 de Ag. de 2011
Yeah, I don't know what he means either. Why doesn't a simple 2D scatterplot of the theta histogram along one axis and the phi histogram along the other axis deliver the information you need for visualizing the distrubution?
Abhinendra
el 9 de Ag. de 2011
Bjorn Gustavsson
el 9 de Ag. de 2011
If you use bins with equal spacing in phi for all theta etc then the area of the solid angle for each bin in not constant, if so it should vary something like dA = sin(theta)*dtheta*dphi. Close to the pole that area decreases as sin theta. To get the pdf you have to normalize it.
Abhinendra
el 9 de Ag. de 2011
Respuestas (3)
Honglei Chen
el 8 de Ag. de 2011
Hi Abhinendra,
You can convert it to rectangular coordinate and then do the surface plot. You just need to make sure that you provide N as the color scale. Here is a quick example.
phi = linspace(0,2*pi,360);
theta = linspace(0,pi,180);
N = ones(180,360);
[P,T] = meshgrid(phi,theta);
surf(N.*sin(T).*cos(P),N.*sin(T).*sin(P),N.*cos(T),N)
HTH
3 comentarios
Abhinendra
el 9 de Ag. de 2011
Honglei Chen
el 9 de Ag. de 2011
Hi Abhinendra,
Assuming that your histogram is smooth, you could interpolate your result in a uniformly sampled (phi,theta) grid. This should help in your case.
HTH
Abhinendra
el 9 de Ag. de 2011
Bjorn Gustavsson
el 8 de Ag. de 2011
0 votos
Well if you want a 3-D histogram (that is with bins in R, theta and phi) you should be well helped with these 3 FEX contributions:
http://www.mathworks.co.uk/matlabcentral/fileexchange/30798-n-d-histogram http://www.mathworks.com/matlabcentral/fileexchange/23897-n-dimensional-histogram http://www.mathworks.com/matlabcentral/fileexchange/31889
They should work with 2-D histograms as well - as would a bunch of other FEX-submissions.
HTH
1 comentario
Abhinendra
el 9 de Ag. de 2011
sree kasturi
el 12 de Sept. de 2011
0 votos
Abhinendra,
Have you looked at Teja's rather elegant solution here? http://www.mathworks.com/matlabcentral/answers/6625-3-d-histogram-in-spherical-coordinates
Categorías
Más información sobre Histograms en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!