Graphically select multiple regions on the x-axis, store those intervals, and highlight those regions
5 views (last 30 days)
Show older comments
Hello,
I'm trying to easily select "bands" for feature detection in signals. It takes a while to prompt the user (by manually typing) for each interval they want to select. I've seen how you can highlight a region using the "patch" function. Can I event bind the left-click and drag to select multiple regions, and right-click to indicate you're finished with making selections?
Ideally it would look like this: example is just y=sin(pi*x)/(pi*x)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/282139/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/282140/image.png)
An example of the patch highlighting is found in https://www.mathworks.com/matlabcentral/answers/387507-highlight-a-section-of-a-plot#answer_309415
An example of getting the x-intervals can be achieved using "get" on the handle for the axes
hax = axes( ... , 'ButtonDownFcn', @OnClickAxes);
function OnClickAxes( hax, evt )
point1 = get(hax,'CurrentPoint'); % hax is handle to axes
rbbox;
point2 = get(hax,'CurrentPoint'); % hax is handle to axes
%points are corners of the rectangle
end
But I don't know how I would put the patch function into the onClickAxes function. Does anyone have experience with real-time graph manipulation? Seems to be a higher tier of matlab expertise that I don't have yet.
0 Comments
Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!