matlab在matlab中选择区域

时间:2012-07-13 16:03:18

标签: matlab plot mouse regions

当我在Matlab中使用绘图时,我遇到了问题。以下是我的Plots问题:

  • 如何在使用鼠标绘制数据后选择区域?
  • 选择区域后如何从该区域获取数据?

任何想法?

1 个答案:

答案 0 :(得分:4)

使用rbbox功能很容易用鼠标选择区域。

首先,将ButtonDownFcn添加到您正在绘制rbbox的轴上。

hax = axes( ... , 'ButtonDownFcn', @OnClickAxes);

然后你在回调中调用rbbox,就像这个

一样
function OnClickAxes( hax, evt )

point1 = get(hax,'CurrentPoint'); % hax is handle to axes
rbbox;
point2 = get(hax,'CurrentPoint'); % hax is handle to axes

end

这里,point1和point2将定义鼠标在数据坐标中绘制的矩形的两个角。在matlab提示符下键入 doc rbbox 以获取更多信息

现在回答你关于2-D情节的第二个问题。

这段代码将提取并返回轴内所有行的选定区域内的数据。

https://gist.github.com/3107790