문제

I have a problem when i am working with plots in Matlab. Following are my issues with Plots:

  • How can one select Regions after plotting data using mouse?
  • After selecting the Regions how to get data from that region?

Any Ideas?

도움이 되었습니까?

해결책

Selecting regions with a mouse is quite easy using the rbbox function.

First you add a ButtonDownFcn to the axes you are drawing rbbox on.

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

Then you call rbbox within the callback like this

function OnClickAxes( hax, evt )

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

end

Here point1 and point2 will define the two corners of the rectangle drawn by your mouse in data coordinates. Type doc rbbox at matlab prompt for more information

Now to answer your second question for 2-D plots.

This bit of code will extract and return the data within the selected region for all lines within an axes.

https://gist.github.com/3107790

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top