matlab selecting regions in matlab plot
문제
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.
제휴하지 않습니다 StackOverflow