有时候用matlab作图时,数据点太多,可以用下面的函数对maker进行设置,这种方法最简单,对数据进行抽样,但是会造成数据的丢失,所以当数据变化缓慢时尚可用,若相邻数据点的值变化较大,则可能导致部分特征失真:
function nummarkers(h,hnum)
% NUMMARKERS takes a vector of line handles in h
% and reduces the number of plot markers on the lines
% to num. This is useful for closely sampled data.
% Created: Magnus Sundberg Feb 08, 2001
% Modified: [email]felonwan@gmail.com[/email] May 25, 2013
lh=length(h);
lhn=length(hnum);
if (lhn~=lh && lhn~=1)
error('The number of markers should be a scalar or a vector with equal length to the number of lines!')
end
for n = 1:lh
if lhn==1
num=hnum;
elseif lhn==lh
num=hnum(n);
end
if strcmp(get(h(n),'type'),'line')
axes(get(h(n),'parent'));
x = get(h(n),'xdata');
y = get(h(n),'ydata');
lx=length(x);
elseif(lx<2*num)
disp('Warning: Dat