I found a solution. It turned out that the problem was that I was only using one radius value for rho1 instead of a list of values. When I changed it to a list of values (i.e. rho1 = linspace(0,1,num_vals)) before doing meshgrid and the conversion from polar to Cartesian coordinates it worked.
How can I get surf or pcolor to be colored properly?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Chandler Williams
el 5 de Jun. de 2017
Respondida: Chandler Williams
el 7 de Jun. de 2017
I have a set of data that represents coloring on a sphere. I want to project half of that data onto a circle. I'm trying to use pcolor and surf (according to the documentation on pcolor), but it seems that no matter what I do the circle just ends up being a solid color. Here is a sample of what my code would look like:
rho1(size(C1,1)) = 1;
theta_c1 = linspace(0,2*pi,size(C1,2));
[theta_c1,rho1] = meshgrid(theta_c1,rho1);
[xc1,yc1] = pol2cart(theta_c1,rho1);
surf(xc1,yc1,zeros(size(xc1)),C1,'Edgecolor','None');
C1 is taken from my data and represents the color data for surf or pcolor. If I just do pcolor(C1), then the colors turn out exactly how I would expect them to, except that they are not on a circle.
Thanks in advance.
0 comentarios
Respuesta aceptada
Más respuestas (1)
KSSV
el 6 de Jun. de 2017
You have C1 in the Cartesian coordinates and xc1, yc1 in polar coordinates. YOu have to change C1 into polar coordinates. Do interpolation, doc interp2.
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!