フィルターのクリア

Color of surf function

3 ビュー (過去 30 日間)
CHANDRABHAN Singh
CHANDRABHAN Singh 2022 年 6 月 2 日
回答済み: KSSV 2022 年 6 月 2 日
I wamt to plot 3 spheres with different colours. But i am unable to do it. I am sharing the code as well. Thank you for your help.
x_min = 5; x_max = 45; y_min = 5; y_max = 45; z_min = 5; z_max = 45;
centre_x(1) = x_min + rand(1)*(x_max-x_min);
centre_y(1) = y_min + rand(1)*(y_max-y_min);
centre_z(1) = z_min + rand(1)*(z_max-z_min);
radius(1) = 4+rand(1)*(5-4);
volume = (4/3)*pi*radius(1)^3; i=2; iteration=0;
plot_sphere(centre_x(1),centre_y(1),centre_z(1),radius(1));
%% plot_sphere function
function [] = plot_sphere(xi,yi,zi,r)
[x, y, z] = sphere;
x = x.*r;
y= y.*r;
z = z.*r;
surf(x+xi, y+yi, z+zi);
%colormap summer
mymap = [1 0 1];
%cmap =
colormap(mymap);
hold on;
axis equal
end

採用された回答

Walter Roberson
Walter Roberson 2022 年 6 月 2 日
You can only use one colormap per axes. You need to use different axes, or you need to supply "CData" in the surf() call passing rgb color data

その他の回答 (1 件)

KSSV
KSSV 2022 年 6 月 2 日
mymap = [1 0 0];

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by