UIAxes - Remove Brushed Data through button click Callback.

I have an app in app designer that containes a UIAxes in 2023a.
I currently enable the brush data function though a button click to allow user selection. Is it possible to use the "Remove Data" or "Replace with NANs" functionality that is normally accessed via a right click on the selected data, through a button click callback?
I'm unsure how to access the functionality in the code.
Thanks

8 件のコメント

Mario Malic
Mario Malic 2023 年 9 月 4 日
I would suggest to take a look at UIFigure property called SelectedObject, it might detect a datatip object, but I am not sure.
Jordan
Jordan 2023 年 9 月 6 日
Hi Mario, thanks for the comment. I had a look however couldn't see the property you refer to here;
Mario Malic
Mario Malic 2023 年 9 月 6 日
Apologies, I totally misunderstood your question.
Can you please explain what you want to again?
Jordan
Jordan 2023 年 9 月 6 日
Hi Mario,
I'll try to re-frame the question a bit;
Currently, if I want to use the brushdata function in a UIAxes, I turn on "Brush" like this = brush(app.UIAxes, 'on')
Then, I select some data on the chart area - If I want to then remove the selected data, I have to right click on the data to bring up a context menu which then allows me to remove the selected data using the "Replace with NaNs" option.
I want to find a way to link the "Replace with NaNs" option to a button click callback event, instead of relying on the right click context menu.
How can I access the functionality held within the context menu of the brush feature so that I can link it to a button click event?
Mario Malic
Mario Malic 2023 年 9 月 6 日
So, you want to reuse the context menu option "Replace with NaNs" that operates on brush data?
Mario Malic
Mario Malic 2023 年 9 月 6 日
Or you want to remove the brushed data without using the context menu, but using a button or something else?
Jordan
Jordan 2023 年 9 月 6 日
Hi Mario, more the latter here. So I want to remove brushed data without using the context menu, but using a button instead. More just to improve user experience than anything.

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

 採用された回答

Mario Malic
Mario Malic 2023 年 9 月 6 日

0 投票

Here is an example of setting brushed data to NaNs, now you have to incorporate this in the callback.
fig = uifigure();
ax = uiaxes(fig);
t = 0:0.1:1;
y = sin(2*pi*t);
h = plot(ax, t, y, '-r');
hold (ax, "on");
h2 = plot(ax, t, 2*y, '-g');
% Uncomment after brushing data
% idx = logical(h.BrushData)
% h.YData(idx) = nan;
% h2.YData(idx) = nan;

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDebugging and Analysis についてさらに検索

製品

リリース

R2023a

質問済み:

2023 年 9 月 4 日

回答済み:

2023 年 9 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by