How can I retrieve data from Matlab plot window with limited axis? Code:
plot(ua,va,'rO');
axis([-320 320 -240 240]); box on;
lh=findall(gcf,'type','line');
xp=get(lh,'xdata');
yp=get(lh,'ydata');
If there is no data on the plot wi开发者_如何学运维ndow, xp and yp will give me data from the plot function (no window itself).
Suppose xp
and yp
are the x and y coordinates of all of the points. You can remove the points outside of [-320 320 -240 240]
like this:
ii = xp < -320 | xp > 320 | yp < -240 | yp > 240;
xp(ii) = [];
yp(ii) = [];
精彩评论