function [cent1,band1,he1,peak1,i]=ybh(err)
yzi=xlsread(‘sheet1.xls‘,‘B2:B261‘);
zd=max(yzi);
zx=max(yzi);
erro=err;
i=1;
n=0;
table=tabulate(yzi);
for m=1:size(table,1)
if table(m,2)~=0
n=n+1;
x(n)=table(m,1);%第一列所有的值
%y(n)=table(m,3)/100;%每一行数出现的频率数
y(n)=table(m,3);%每一行数出现的频率数
y1(n)=table(m,2);%每一行数出现的频率数
end
end
plot(x,y1,‘r‘);
hold on;
varz=var(yzi);%求方差
%数据规整
while max(y)>=erro
[my,I]=max(y);
core=x(I);
delta=0.1;
%初始的delta可以设置
z=y;
while min(z)>=(erro+0.005)
delta=delta+0.01;
%步长可以设置
z=y-my*exp(-((x-core).^2)/(2*delta^2));
end
delta=delta-0.01;
y=y-my*exp(-((x-core).^2/(2*delta^2)));
peak1(i)=my;
cent1(i)=core;
band1(i)=delta;
i=i+1;
end
for k=1:(i-1)
he1(k)=sqrt(varz-band1(k)^2);
end
k0=i-1;
for gg=1:i-1
for jsx=cent1(gg)-4*band1(gg):0.001:cent1(gg)+4*band1(gg)
y=peak1(gg)*exp(-((jsx-cent1(gg)).^2/(2*band1(gg)^2)));
plot(jsx,y);
hold on;
end
end