How can I automatically select two points in a plot?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
How can I automatically select two points in a plot?
I use ginput manually, but I want to automate the selection.
You can see part of the code below:
x = (1:length(compositfilt));
y = compositfilt;
hold on
grid on
xlabel('time [s]');
ylabel('voltage');
plot(x,y)
[cut1, ~] = ginput(2);
cut1 = round(cut1);
compositfilt = compositfilt(:,cut1(1):cut1(2));
clf
x = (1:length(compositfilt));
y = compositfilt;
plot(x , y)
0 commentaires
Réponses (1)
Cameron B
le 13 Jan 2020
Select them as in producing data tips? If that's the case, then see the code below. If not, then please explain what you'd like a little bit more.
xx = 1:1:30;
yy = sqrt(xx);
fig = figure;
figplot = plot(xx,yy);
CursorPt1 = createDatatip(datacursormode(fig),figplot);
CursorPt2 = createDatatip(datacursormode(fig),figplot);
CursorPt1.Marker = 'o';
CursorPt2.Marker = 'o';
CursorPt1.MarkerSize = 5;
CursorPt2.MarkerSize = 5;
CursorPt1.Position = [xx(3),yy(3)];
CursorPt2.Position = [xx(6),yy(6)];
0 commentaires
Voir également
Catégories
En savoir plus sur Data Exploration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!