0
votes

I have a set of n=8000 cartesian coordinates X,Y and Z as vectors and also a vector V of same size which I want to use as values to create a heatmap on a sphere.

I saw this link (visualization of scattered data over a sphere surface MATLAB), but I don't understand how I convert this set of data into a meshgrid for plotting using surf.

Almost every example I saw uses meshgrids. Right now, I am doing by plotting a sphere and then use scatter3 to plot my points as big balls and try to smooth them later. I looks like this: enter image description here

I would like to get the figure as the plotting of the example in that link, where he uses:

k = 5;
n = 2^k-1;
[x,y,z] = sphere(n);
c = hadamard(2^k);
surf(x,y,z,c);
colormap([1  1  0; 0  1  1])
axis equal

EDIT:

(Sorry for taking so long to reply, the corona crises kept away from work) What I am actually doing is:

for i=1:numel(pop0n)
ori(i,:)=ori(i,:)/norm(ori(i,:));
end

x = ori(:,1); 
y = ori(:,2); 
z = ori(:,3); 

%// plot
m=100;
[aa,bb,cc] = sphere(m);
surf(aa,bb,cc,ones(m+1,m+1)*min(pop0n))
hold on
colormap jet;
scatter3(x,y,z,400,pop0n/norm(pop0n),'filled');
colorbar
shading interp

The array 'ori' is 8000x3, and contains the x, y and z coordinates of the points I want to plot and pop0n is a 8000 sized vector with the intensities of each coordinate.

My main question is how do I transform my x, y, z and pop0n, that are vectors, into 2D arrays (meshgrid) to use surf? Because I cannot simply do surf(x,y,z,pop0n) if they are vectors.

Thanks in advance

1
It is unclear how your question is different to one you linked. Have you tried griddata?David
and we shoud assume that the x,y,z you have are points on a sphere?bla
Don't use scatter3. Use surf and send your vector V as the fourth parameters (as in the example you link).Hoki
Hoki: That's what I want to do but don't know how... David: The diference is the shape of the variables and how to convert from one to the other. I am not familiar with griddata. I will check it. ThanksCayo Emilio
And yes, x,y,z are points on a sphereCayo Emilio

1 Answers

0
votes

As David suggested, griddata does the job.

What I did was:

for i=1:numel(pop0n)
ori(i,:)=ori(i,:)/norm(ori(i,:));
end

x = ori(:,1); 
y = ori(:,2); 
z = ori(:,3); 

%// plot
m=100;
[aa,bb,cc] = sphere(m);
v = griddata(x,y,z,pop0n,aa,bb,cc,'nearest');
surf(aa,bb,cc,v)
colormap jet;
colorbar
shading interp