⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simu2data1.m

📁 化学计量方面的好助手
💻 M
字号:
function SIMU2DATA

clear; clc
close all
%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]
% global X
 
%%%parameter of 2_way data%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
h = [0.04 0.12  ];%0.08 0.05];
sgm =[  3 6  ];%3 2 ];
% h = [     0.04 0.05 0.06 0.03];
% sgm =[  3 3 3 3 ];


h1 =[ 1.0000      0.8 ];
cen1 = [    12  23];
sgm1 = [      5.0000  3 ];
h2 =[      0.9000   0.7 ];
cen2 = [  34  60  ];
sgm2 = [     7.6000 6.8];
h3 =[      1.0000 1.0];
cen3 = [     14 55];
sgm3 = [      6.0000  2];
%h4=[ 0.5000    0.9000  0.9 ];
%cen4 = [48    59   52];
%sgm4 = [6.20000    7.6000  7];
noise = 0.0010;
num_w =60;
num_t =100;

%%%%%chromatograpy peaks'postion%%%%%%%%%%%%%%%%%%%% 

%cen=[35    45    55   65   75 ]; 
%cen=[35    50    65   80   95 ];  
cen=[ 25 61  ];% 59] ;  
% cen=[   26 31 38 42] ;  

%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

 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%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';

save('purechromy.mat','purechromy')


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));%+h3(i)*exp(-(j-cen3(i))^2/(2*sgm3(i)^2));
   end
end

simuspecy=x;
 
y=yij'*simuspecy';%%%a 2_way data without noise%%%
y=y+max(max(y))*randn([num_t,num_w])*noise;%%%with noise

figure(90)
zz=yij(1,:)'*simuspecy(:,1)';
subplot(2,2,1)
surfc(zz)
zzz=yij(2,:)'*simuspecy(:,2)';
subplot(2,2,2)
surfc(zzz)
subplot(2,2,3)
surfc(y)

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
 
simuspecy=simuspecy';
% figure(3)
% subplot(2,2,1);
% plot(simuspecy(1,:) );
% subplot(2,2,2);
% plot(simuspecy(2,:) );
figure(8)
plot(simuspecy(1,:)/norm(simuspecy(1,:),2),'g')
hold on
figure(7)
plot(simuspecy(2,:)/norm(simuspecy(2,:),2))
hold on
save('simuspecy.mat','simuspecy')
%%%%%%%%%%%%%%%%save the 2_way data%%%%%%%%%%%%%%%%
X=y;

[U,S,V]=svd(X);

% X=U(:,1:2)*S(1:2,1:2)*V(:,1:2)';
U=U*S;
save('U.mat','U')
save('X.mat','X')
figure(33)
subplot(2,2,1)
plot(U(:,1))
subplot(2,2,2)
plot(U(:,2))
subplot(2,2,3)
plot(U(:,3))
figure(334)
subplot(2,2,1)
plot(V(:,1))
subplot(2,2,2)
plot(V(:,2))
subplot(2,2,3)
plot(V(:,3))

% save simuspecy.mat
%save ('D:\MATLAB6p5\work\data\X','X','-mat');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

figure(1)
plot(sum(yij)','c');
plot(yij(1,:)/norm(yij(1,:),2),'g')
hold on;
plot(yij(2,:)/norm(yij(2,:),2))

% plot(yij'/norm(yij',2))
 
hold on
xlabel('time scan point');
ylabel('absorption A');
drawnow
 
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -