Segment of Graph Extraction
Show older comments
Can you use any plotting tools to extract a segment of a graph and replot that segment into a new figure or subplot?
Accepted Answer
More Answers (1)
Gerd
on 17 Jun 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
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!