How to plot ellipses by clicking on the points. I have a 100*100 cm grid and I would like to generate ellipses in it by clicking different positions. Is there a way to do it? The ellipses can intersect and thereby I need to detect the high region of intersection.

댓글 수: 5

KSSV
KSSV 2018년 9월 17일
You want to click and make the center? Do you have minor, major axis data? Or you want to click the entire ellipse?
Ramesh Bala
Ramesh Bala 2018년 9월 17일
function gridplot
axis([0 100 0 100])
rectangle('Position',[0 0 100 100]) grid on
hold on
X = [10 90 90 20 50 90 40 20 90 ];
Y = [10 10 20 30 50 60 70 80 90 ];
% Create plot plot(X,Y,'MarkerFaceColor',[0.847058832645416 0.160784319043159 0],...
'Marker','o',...
'LineStyle','none',... 'Color',[1 0 0]);
txt1 = ' 7';
text(X(1),Y(1),txt1)
txt2 = ' 2'; text(X(2),Y(2),txt2) txt3 = ' 3';
text(X(3),Y(3),txt3)
txt4 = ' 4'; text(X(4),Y(4),txt4) txt5 = ' 5';
text(X(5),Y(5),txt5)
txt6 = ' 6'; text(X(6),Y(6),txt6) txt7 = ' 1';
text(X(7),Y(7),txt7)
txt8 = ' 8'; text(X(8),Y(8),txt8) txt9 = ' 9';
text(X(9),Y(9),txt9)
xlabel({'Length','(cm)'})
ylabel({'Width', '(cm)'})
ax = gca; ax.XRuler.Axle.LineWidth = 2; ax.YRuler.Axle.LineWidth = 2;
GridLineWidth = 2;
end
This is my code, I would like to select marker points and create ellipses from it.
Ramesh Bala
Ramesh Bala 2018년 9월 17일
Ramesh Bala
Ramesh Bala 2018년 9월 17일
whether imellipse or drawellipse works in this case?
Ramesh Bala
Ramesh Bala 2018년 9월 18일
I believe imellipse is already a preloaded one where one just clicks and drag the ellipse, can it be modified based on the above case?

댓글을 달려면 로그인하십시오.

 채택된 답변

KSSV
KSSV 2018년 9월 18일
편집: KSSV 2018년 9월 18일

1 개 추천

figure
hold on
axis equal
t=-pi:0.01:pi;
for i = 1:10
a=10; % horizontal radius
b=5; % vertical radius
[x0,y0] = getpts() ;
x=x0(1)+a*cos(t);
y=y0(1)+b*sin(t);
plot(x,y)
drawnow
end

댓글 수: 7

Ramesh Bala
Ramesh Bala 2018년 9월 18일
Thanks KSSV,I'm expecting to do it in another way with user interface by direct clicks
KSSV
KSSV 2018년 9월 18일
Edited answer....double click at a point, when figure is prompted
Ramesh Bala
Ramesh Bala 2018년 9월 18일
That's interesting good option drawnow ,never knew that.Thanks.But the picture obtained looked like this with varying thickness?
KSSV
KSSV 2018년 9월 18일
There is a problem with clicking....you should double click ..fast...edited the code...
Ramesh Bala
Ramesh Bala 2018년 9월 18일
thanks, lemme have a check.Is there any reason for keeping a,b constant. Can't it be like
a = (x0(1)+x0(2))./2;
b = (y0(1)+y0(2))./2;
or do you have other choices?
KSSV
KSSV 2018년 9월 18일
That is your choice..you should be knowing....they determine the size/ radii of ellispes.
Thanks for the comments; this is the overall script created. But the problem is that it's moving away from the boundary. Of course, I know it's based on the radii size as we mention, but is there any way to constrain that within boundary ??
function ellipsedrawon
clear
close uiopen
t=-pi:0.01:pi;
for i = 1:20
%getting the points
[x0,y0] = ginput(2) ;
% a =10;
% b =5;
% a = (x0(1)+x0(2))./2; % horizontal radii
b = (y0(1)+y0(2))./2; % vertical radii
% x,y ellipse plot
x=x0(1)+a*cos(t);
y=y0(1)+b*sin(t);
plot(x,y)
drawnow
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

질문:

2018년 9월 17일

댓글:

2018년 10월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by