How to plot color ball use matlab?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
z cy
el 20 de Oct. de 2021
Comentada: Star Strider
el 22 de Oct. de 2021
What I want know how to plot color ball use matlab? And we need to get the [x,y,z] for each color point. Thanks! The white color can be ignored.
0 comentarios
Respuesta aceptada
Star Strider
el 20 de Oct. de 2021
This is an interesting problem!
This should get you started —
Facets = 40;
numPatches = fix(Facets/5);
[X,Y,Z] = sphere(Facets-1);
figure
hs = surf(X, Y, Z, 'EdgeColor','none');
colormap(turbo(fix(Facets/3)))
hold on
idxk = 1:fix(Facets/numPatches);
for k = 1:numPatches
idx = idxk + numel(idxk)*(k-1);
hs.CData(:,idx) = k-fix(Facets/2);
end
hold off
grid on
axis('equal')
view(50,30)
rotate(hs, [0.5 1 1],45)
NOTE — The surface patches are defined by the CData colormap colors that go from -1 to +1 so whatever the desired colormap is (I chose turbo that was introduced in R2021a) will automatically map to those values. (After a false start using patch, this turned out to be reasonably straightforward.) The loop works by selecting the columns defined by ‘idx’ and then colouring them according to the value of the colormap at that point. The rotate call is optional, and simply inclines the sphere object so that more of its patches are visible.
Experiment to get different results.
.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!