How to plot color ball use matlab?
4 ビュー (過去 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.
0 件のコメント
採用された回答
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!