matlab在matlab图中选择区域

Sat*_*msi 1 mouse matlab plot regions

当我在 Matlab 中处理绘图时遇到问题。以下是我的绘图问题:

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

有任何想法吗?

cho*_*and 5

使用 rbbox 函数用鼠标选择区域非常容易。

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

hax = axes( ... , 'ButtonDownFcn', @OnClickAxes);
Run Code Online (Sandbox Code Playgroud)

然后你在回调中调用 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
Run Code Online (Sandbox Code Playgroud)

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

现在回答关于二维图的第二个问题。

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

https://gist.github.com/3107790