How to plot color ball use matlab?

3 次查看(过去 30 天)
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.

采纳的回答

Star Strider
Star Strider 2021-10-20
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 个评论
z cy
z cy 2021-10-22
Thanks for your answer!!!
Star Strider
Star Strider 2021-10-22
As always, my pleasure!
Solving this problem was fun!
.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by