2

I have a code on matlab that allows me to plot a series of ellipses, what I am trying to do it to fill each of them with a gradiant color based on 'arcsin(b/a)' The number will go from 0° (straight line) to 90° (pure circle). So each ellipse will have a uniform color, but the colors of each ellipse will be different if that makes sense. That's my code

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;

Let me know if I need explain in a different way. Thank you guys Dorian

0 Answers0