フィルターのクリア

RBBOX problem

9 ビュー (過去 30 日間)
Silvia
Silvia 2011 年 7 月 15 日
回答済み: Christophe 2019 年 10 月 10 日
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 件のコメント
David Fergenson
David Fergenson 2015 年 7 月 2 日
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

サインインしてコメントする。

回答 (2 件)

Paulo Silva
Paulo Silva 2011 年 7 月 15 日
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 件のコメント
Silvia
Silvia 2011 年 7 月 15 日
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 2011 年 7 月 15 日
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

サインインしてコメントする。


Christophe
Christophe 2019 年 10 月 10 日
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 ?

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by