Filter löschen
Filter löschen

RBBOX problem

9 Ansichten (letzte 30 Tage)
Silvia
Silvia am 15 Jul. 2011
Beantwortet: Christophe am 10 Okt. 2019
Hello, I am using rbbox as this example:
point1 = get(gca,'CurrentPoint'); % button down detected
finalRect = rbbox; % return figure units
point2 = get(gca,'CurrentPoint'); % button up detected
But if I look at point1 and point2 they are the same point,so it doesn't work correctly and I don't know why this is happening. Thank you very much
  1 Kommentar
David Fergenson
David Fergenson am 2 Jul. 2015
This may be a workaround for you if you aren't concerned as to which corner of the box was clicked first. Simply compute opposite corners using the values returned by rbbox into finalRect. One corner will be finalRect(1:2) and the other will be [finalRect(1)+finalRect(3), finalRect(2)+finalRect(4)];
Hope this helps. -Davio

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Paulo Silva
Paulo Silva am 15 Jul. 2011
You are using the code in a wrong way, you press and realease the button in the same point without moving the mouse.
Press the button, keep button pressed while moving the mouse away from point1, release the button, now point1 is diferent from point2.
k = waitforbuttonpress;
point1 = get(gca,'CurrentPoint') % button down detected
finalRect = rbbox; % return figure units
point2 = get(gca,'CurrentPoint') % button up detected
point1 = point1(1,1:2); % extract x and y
point2 = point2(1,1:2);
p1 = min(point1,point2); % calculate locations
offset = abs(point1-point2); % and dimensions
x = [p1(1) p1(1)+offset(1) p1(1)+offset(1) p1(1) p1(1)];
y = [p1(2) p1(2) p1(2)+offset(2) p1(2)+offset(2) p1(2)];
hold on
axis manual
plot(x,y)
  2 Kommentare
Silvia
Silvia am 15 Jul. 2011
Yes, my problem is that I'm moving the mouse. I press the button, keep button pressed while moving the mouse and I release the button. However both points are the same, it detects only first point and I do not know why.
Paulo Silva
Paulo Silva am 15 Jul. 2011
neither do I, try this
axes
ginput(2)
Click on two points of the axes and see if you get two diferent values or not

Melden Sie sich an, um zu kommentieren.


Christophe
Christophe am 10 Okt. 2019
Hello,
I have the same problems with Matlab R016b.
It is very frustrating because it is a random bug. It can works perfectly and soudainly fails with point1 and point2 egals.
Is there a workaround ?

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by