设置matlab作图数据的个数

在使用Matlab绘图时,面对大量数据点,可以采取抽样的方式简化图表。这种方法虽然可能导致数据丢失,但在数据变化缓慢时仍适用。然而,如果数据点间变化剧烈,此方法可能使图表特征失真。示例中展示了将marker设置为10的绘图效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

有时候用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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值