3D histogram plot for a tensor data

Hey everyone,
I am begineer in matlab with limited experience in programming. I have a tensor data (x,y,z values) of contact orientation (about 10000 data values). I want to plot these orientation data using a sphere or icosphere such that length of bins represent the number of points oriented in that particular direction. Can anyone please provide some reference code to solve this problem.
I am also adding the data for your reference.
Thanking you in advance,
Sarath

Answers (1)

Rishik Ramena
Rishik Ramena on 18 Mar 2021
Have a look at the solution posted here. You can use cart2sph to convert your cartesian coordinates to spherical coordinates. Or you can modify the code to work with your cartesian tensor data.

3 Comments

Thanks Mr. Rishik for the reply and suggestion on cart2sph. Using this I was able to convert the data into spherical coordinates ([azimuth,elevation,r]). I have checked the solution provided by Teja Muppirala previously also but I am not able to figure out how to define theta_vec, phi_vec in his code (is it based on the number of data? In my case it is 10000 values(x,y,z) approx). And Histogram data H should represent the orientation (based azimuth and polar angle). Can you please suggest how to take theta_vec, phi_vec values.
Thanking you in advance,
best wishes
Sarath
The 'theta', 'phi' and 'H' correspond to the azimuth,elevation and r respectively.
@Rishik: I guess H should be a vector with size which is a combination of size of theta and phi, therefore H can't be r as 'r' is a column vector. What I did was I have defined theta_vec and phi_vec as
For 50 data points
theta_vec = linspace(0,2*pi,50);
phi_vec = linspace(0,2*pi,50);
[az,el,r] = cart2sph(x(1:50),y(1:50),z(1:50)) % x,y,z are contact orientations % r is coming as 1 for all the 50 points
H = 100*meshgrid(az,el); % If use r here as you suggested it is showing error as it is not equivalent to the theta x phi size
Though the code is running, It is not correctly representing the required orientation may be I done some thing wrong with the 'H'.
Can pls let me know where I am going wrong.
Thanking you in advance,
best wishes
Sarath

Sign in to comment.

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!