Brush data returns empty 0x0 ogical

1 回表示 (過去 30 日間)
Feri
Feri 2020 年 2 月 29 日
コメント済み: Feri 2020 年 3 月 3 日
Hello,
I have been looking around to find a way to automatically save the brushed data, but am stuck at the first step.
Using the following lines:
% find all objects with the property BrushData
hB = findobj(gcf,'-property','BrushData');
% extract the brush data
data = get(hB,'BrushData');
What I receive is an empty logical output.
Does anyone know how to solve this? I can't use the function in FileExchange "selectdata".
Or any suggestion on how to automatically save the brushed data and exit the brush mode in the current axes?
Thank you in advance.

採用された回答

Divya Gaddipati
Divya Gaddipati 2020 年 3 月 3 日
You can refer to the following snippet and modify it according to your need:
x = rand(20,1);
y = rand(20,1);
Handle = scatter(x,y);
b = brush;
b.Enable = 'on';
After selecting the data, you can get the brushed data using the get command
xd = get(Handle, 'XData');
yd = get(Handle, 'YData');
brush = get(Handle, 'BrushData');
brushed_data_x = xd(logical(brush));
brushed_data_y = yd(logical(brush));
b.Enable = 'off';
Hope this helps!
  1 件のコメント
Feri
Feri 2020 年 3 月 3 日
Excellent, thank you so much.
The way it worked for me was that I had to put a break point, brush the data, the run the rest of the code to collect coordinates. Is the a way that I can do this without the breakpoint? Because I have to implemet this into a GUI.
Thanks a million.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by