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

4 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Ramnarayan Krishnamurthy
Ramnarayan Krishnamurthy el 3 de Oct. de 2017
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.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by