【发布时间】:2017-02-06 16:08:05
【问题描述】:
我想在 MATLAB 中绘制一个三等分的圆,并用不同的 RGB 颜色填充每三分之一。
我首先画了一个圆圈并用一种颜色填充它。然后我把那个圆圈分成三个相等的区域。现在我试图为圆圈的每个“切片”赋予不同的颜色。有人能帮我吗?
提前谢谢你。
这是我的代码:
% 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
【问题讨论】:
标签: matlab plot colors matlab-figure geometry