在Matlab上用渐变颜色填充椭圆

时间:2015-03-06 17:07:29

标签: gradient matlab-figure fill ellipse drawellipse

我在matlab上有一个代码,可以让我绘制一系列的椭圆,我试图用它来填充每一个基于'arcsin(b / a)'的渐变颜色。这个数字将来自0°(直线)至90°(纯圆)。因此每个椭圆将具有均匀的颜色,但是如果有意义的话,每个椭圆的颜色将是不同的。 那是我的代码

clearvars -except data colheaders

data(:,9)=data(:,9)*pi/180; % Convers Column 9 (angle of rotation) in rad
data(:,6)=1196-data(:,6); % Reset the Y coordinate axis to bottom left

theta = 0 : 0.01 : 2*pi;

for i=1:size(data,1)
x = data(i,7)/2 * cos(theta) * cos(data(i,9)) - data(i,8)/2 * sin(theta) * sin(data(i,9)) + data(i,5);
y = data(i,8)/2 * sin(theta) * cos(data(i,9)) + data(i,7)/2 * cos(theta) * sin(data(i,9)) + data(i,6);
plot(x, y, 'LineWidth', 1);
hold on
% Columns (5,6) are the centre (x,y) of the ellipse
% Columns (7,8) are the major and minor axes (a,b)
% Column 9 is the rotation angle with the x axis

text(data(i,5),data(i,6),[num2str(i)]) % Assigns number to each ellipse
end

axis equal;
xlim([0 1592]);
ylim([0 1196]);
grid on;

如果我需要以不同的方式解释,请告诉我。 感谢你们 道连

0 个答案:

没有答案
相关问题