How to plot color ball use matlab?

4 ビュー (過去 30 日間)
z cy
z cy 2021 年 10 月 20 日
コメント済み: Star Strider 2021 年 10 月 22 日
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 Center および File ExchangeSurface 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