Segment of Graph Extraction
Afficher commentaires plus anciens
Can you use any plotting tools to extract a segment of a graph and replot that segment into a new figure or subplot?
Réponse acceptée
Plus de réponses (1)
Gerd
le 17 Juin 2011
Hi Daniel,
I don't know any plotting tool in Matlab but with some lines of code it shouldn't be a problem.
xlimit=get(gca,'XLim');
nearest= min(abs(a-xlimit(1)));
% find index of nearest time value
indexX1 = find(a==xlimit(1)+nearest | a==xlimit(1)-nearest);
nearest= min(abs(a-xlimit(2)));
% find index of nearest time value
indexX2 = find(a==xlimit(2)+nearest | a==xlimit(2)-nearest);
figure;
plot(a(indexX1:indexX2),b(indexX1:indexX2));
First, I would check the XLimits of the current axes and determine the nearest point in the time vector. Then plotting with the new indices. Of course you can also plot in a subplot.
Gerd
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!