Je veux dessiner un cercle divisé en tiers et remplir chaque tiers avec une couleur RVB différente, dans MATLAB. J'ai commencé en dessinant un cercle et en remplissant tout d'une seule couleur. Ensuite, j'ai divisé ce cercle en 3 zones égales. Maintenant j'essaye de donner une couleur différente à chaque 'tranche' du cercle. Est-ce que quelqu'un peut m'aider?Tracer un cercle divisé en tiers avec des couleurs différentes each_ MATLAB
Merci d'avance.
Voici mon code:
% FilledCircle3 : function that takes 5 inputs
%
% Call the function:
% FilledCircle3(x0,Row,Radius,N,Color)
%
% Inputs Types
% ------------
% x0 - Integer, Float
% y0 - Integer, Float
% Radius - Integer, Float
% N - Integer
% Color - Character String
%
% Notes on N: The more N increases, the more accurate is the circle
% The standard value for N is 256
%
% Notes on Color:
% 'b' blue
% 'g' green
% 'r' red
% 'c' cyan
% 'm' magenta
% 'y' yellow
function []=FilledCircle3(x0,y0,Radius,N,Color)
if(N<=1)
error('N must be greater than 1');
end
if (Color ~='b') && (Color ~='g') && (Color ~= 'r') && (Color ~='c') && (Color ~='m') && (Color ~='y')
error('This is not an available color');
end
hold on
axis equal
t=(0:N)*2*pi/N; %t=-pi:0.01:pi
x=Radius*cos(t)+x0;
y=Radius*sin(t)+y0;
plot(x,y,Color, fill(x,y,Color));
hold on
% Divide circle into 3 sectors
n=3
tet=linspace(-pi,pi,n+1)
xi=r*cos(tet)+x0
yi=r*sin(tet)+y0
for k=1:numel(xi)
plot([x0 xi(k)],[y0 yi(k)])
hold on
end
Merci! Y at-il une raison pour laquelle vous avez choisi hsv colors @Suever? – Mraquel
@Mraquel Les couleurs que j'ai choisies sont arbitraires. Vous pouvez utiliser toutes les couleurs que vous voulez. – Suever