Plot a signal, manually brush data range, and generate new variable

8 ビュー (過去 30 日間)
Sean Quisenberry
Sean Quisenberry 2017 年 9 月 26 日
回答済み: Ramnarayan Krishnamurthy 2017 年 10 月 3 日
I am looking for a means to plot a signal, and have the brush function automatically on. Manually select that data range (mostly the peaks), and then automatically create a new variable (with a predefined name).
I am trying to cut out the select brush data, then right-click the data, select create new variable and type in the new name.

回答 (1 件)

Ramnarayan Krishnamurthy
Ramnarayan Krishnamurthy 2017 年 10 月 3 日
To programmatically implement selecting brush data, saving it to a newly created variable, you can try the following approach:
% Plot Random data
a = plot(rand(10,1));
% Enable Brush
brush on
% Now manually select brush data on the plot using the mouse
% then run the lines below
% Obtain indices of brushed values
ind = find(get(a, 'BrushData'));
% Obtain x and y brushed values
brush = logical(get(a, 'BrushData'));
xd = get(a, 'XData');
yd = get(a, 'YData');
brushed_x = xd(brush);
brushed_y = yd(brush);
There is an elaborate discussion of the above solution at:
A few other approaches that may be applicable to your use case are:
Of particular interest may be the "Graphical data selection tool" on File exchange.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by