📄 simu2data.m
字号:
function SIMU2DATA
%simulate a 2-way data (matrix)
%chrom is a matrix with peak height,peak position and peak variance of several chromatography peaks
%such as chrom =[1 20 1;1.5 40 0.8;2 70 1.2]
%[x1,y1]=simu1da(3,14,[1 1 1],[25 39 33],[7 7 8],[.5 .6 .7],[42 59 64],[8 7.6 9],.02,c);
%h=[0.7 0.3 ];
%cen=[45 42 ];
%sgm=[10 4 ];
%h1=[1 1 ];
%h2=[.5 .6 ];
%cen1=[25 39 ];
%cen2=[42 59 ];
%sgm1=[7 5 ];
%sgm2=[8 7.6 ];
%noise=0.01;
%num_t=100;
%num_w=100;
%%%parameter of 2_way data%%%%%%%%%%%%%%%%%%%%%%%%%%%
h = [ 1 1 1 1 1];
%cen =[20 20 20 20 20];
sgm =[4 4 4 4 4];
h1 =[ 1.0000 1.0000 1.0000 0.6000 0.3000];
cen1 = [25 39 33 19 30];
sgm1 = [ 7.0000 7.0000 8.0000 9.0000 8.8000];
h2 =[ 0.5000 0.6000 0.7000 1.0000 1.0000];
cen2 = [42 59 64 40 50];
sgm2 = [8.0000 7.6000 9.0000 6.0000 8.1000];
noise = 0.0200;
num_w = 80;
num_t =200;
%%%%%chromatograpy peaks'postion%%%%%%%%%%%%%%%%%%%%
%cen=[35 45 55 65 75 ];
%cen=[35 50 65 80 95 ];
cen=[35 37 45 69 75] ;
%cen=[35 60 85 110 135] ;
%cen=[35 65 95 125 155] ;
%cen=[35 68 101 134 165 ] ;
%cen=[35 69 103 137 171 ] ;
%cen=[35 72 109 146 183 ] ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
m=size(h,2);
n=size(h1,2);
if m~=n
errordlg('色谱和光谱对应的组分数(即谱峰数目)必须相等!');return;
end
m=size(cen,2);
n=size(cen1,2);
if m~=n
errordlg('色谱和光谱对应的组分数(即谱峰数目)必须相等!');return;
end
m=size(sgm,2);
n=size(sgm1,2);
if m~=n
errordlg('色谱和光谱对应的组分数(即谱峰数目)必须相等!');return;
end
%xmax1=round(1.2*max(chrom(:,2)));
%xmax2=round(1.2*max(spec(:,2)));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%simulation programme%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=1:80;
for i=1:m
for j=1:num_t
yij(i,j)=h(i)*exp(-(j-cen(i))^2/(2*sgm(i)^2));
end
end
purechromy=yij';
for i=1:n
for j=1:num_w
x(j,i)=h1(i)*exp(-(j-cen1(i))^2/(2*sgm1(i)^2))+h2(i)*exp(-(j-cen2(i))^2/(2*sgm2(i)^2));
end
end
simuspecy=x;
purespecy=simuspecy;
y=yij'*simuspecy';%%%a 2_way data without noise%%%
%y=y+max(max(y))*randn([num_t,num_w])*noise;%%%with noise
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%save the 2_way data%%%%%%%%%%%%%%%%
X=y;
save X.mat
%save ('D:\MATLAB6p5\work\data\X','X','-mat');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
plot(purespecy);
xlabel('spectral scan point');
ylabel('absorption A');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -