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

📄 mainroutine.m

📁 算荧光衰减时间或者寿命的软件.matlab语言编写.
💻 M
字号:
function [ExportData, FittedDecays] = MainRoutine(file,StartTime,EndTime,Amp,Life,InstCurveNum,DataCurveNum,components,lb,ub,TimePerChan)

fid2 = fopen([file(1:end-4) '_Decay' int2str(DataCurveNum) '-stats.doc'],'w'); % Data saved to this file
raw = load(file);

InstrumentResponse = raw(:,InstCurveNum); %Import Data Set
Data = raw(:,DataCurveNum); %Import Data Set
InstrumentResponse = InstrumentResponse/max(InstrumentResponse)*max(Data);
 
iback = -1*mean(InstrumentResponse(EndTime-100:EndTime))-1;
Dback = sqrt(mean(Data(EndTime-100:EndTime)));

TimeShift = 0; % shift in time variable

starting = [Amp Life iback Dback TimeShift]; starting =  starting';

 
 InstrumentResponse = InstrumentResponse(StartTime:EndTime);
 Data = Data(StartTime:EndTime);
 Time = (0:TimePerChan:(TimePerChan*size(Data)-TimePerChan))';
 BatchLength = length(Data);
 pp=ppcreate(Time,InstrumentResponse,'pchip');

options = optimset('PrecondBandWidth', Inf, 'display','Iter','Largescale', 'on',...
    'TolX',1e-9, 'TolFun',1e-9, 'LevenbergMarquardt', 'On', ...
    'MaxFunEvals',50000,'MaxIter',50000);


if components == 1
    %%%%%%%%%%%%% First Run  
    values = [1 4 7 8 9];
    starting = starting(values); lb = lb(values); ub = ub(values);
    [FittedDecays] = lsqcurvefit('lifeFunc1com',starting,Time,Data,lb,ub,options,pp);
    ExportData = plots1com(FittedDecays,Time,pp,InstrumentResponse,Data,fid2);

elseif components == 2
    %%%%%%%%%%%%% Second Run
    values = [1 2 4 5 7 8 9];
    starting = starting(values);lb = lb(values); ub = ub(values);
    [FittedDecays] = lsqcurvefit('lifeFunc2com',starting,Time,Data,lb,ub,options,pp);
    ExportData = plots2com(FittedDecays,Time,pp,InstrumentResponse,Data,fid2);
    
elseif components == 3
    %%%%%%%%%%%%% Third Run
   values = [1 2 3 4 5 6 7 8 9];
   starting = starting(values);lb = lb(values); ub = ub(values);
   [FittedDecays] = lsqcurvefit('lifeFunc3com',starting,Time,Data,lb,ub,options,pp);
   ExportData = plots3com(FittedDecays,Time,pp,InstrumentResponse,Data,fid2);
 end
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Fit Plot
fclose(fid2);

fid3=fopen([file(1:end-4) '_Decay', int2str(DataCurveNum),'-Results_' int2str(components), 'com.txt'],'wt');
fprintf(fid3,[repmat('%f\t',1,4) '%f\n'],ExportData.');
fclose(fid3);

⌨️ 快捷键说明

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