From 821ed661a478765e4ef8920053fb9c4342b37b07 Mon Sep 17 00:00:00 2001 From: sakul-45 <81963567+sakul-45@users.noreply.github.com> Date: Wed, 14 Jul 2021 13:49:55 +0200 Subject: [PATCH] Implemented "thyme" fitting function --- simulation_TREPR.m | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/simulation_TREPR.m b/simulation_TREPR.m index 16f1189..1bf53f8 100644 --- a/simulation_TREPR.m +++ b/simulation_TREPR.m @@ -1,4 +1,4 @@ -function [params] = simulation_TREPR(Exp,Sys,params) +function [params] = simulation_TREPR(Exp,Sys0,params) %SIMULATION_TREPR Summary of this function goes here % % Detailed explanation goes here @@ -19,10 +19,12 @@ ax = axes(plotpanel); ax.XLabel.String = 'magnetic field'; ax.YLabel.String = 'Intensity'; %plot manual simulation -[bfield,spec] = pepper(Sys,Exp); +[bfield,spec] = pepper(Sys0,Exp); spec_norm = spec/max(spec); % normalize the simulation plot(ax,0.1*params.Field_Vector,params.max_mean,'r',... bfield,spec_norm,'b','LineWidth',1.2) +xlabel 'Magnetic Field / mT' +ylabel 'EPR signal / A. U.' legend('experimental','simulation') axis tight @@ -284,13 +286,38 @@ uicontrol(InpTx); %passes focus to first input uiwait(fig) %% Callback functions - function SimStartButtonPushed(src,event) - + function BestSys = SimStartButtonPushed(src,event) + %get Vary and Opt from Input + varT1 = str2double(get(InpTx,'String')); + varT2 = str2double(get(InpTy,'String')); + varT3 = str2double(get(InpTz,'String')); + Vary.Temperature = [varT1 varT2 varT3]; + varD = str2double(get(InpD,'String')); + varE = str2double(get(InpE,'String')); + Vary.D = [varD varE]; + varGauss = str2double(get(InpGauss,'String')); + varLor = str2double(get(InpLor,'String')); + Vary.lw = [varGauss varLor]; + Vary.g = str2double(get(InpG,'String')); + FitOpt.Method = get(InpMeth,'String'); + FitOpt.Scaling = get(InpScal,'String'); + %perform fit + Sys0.Temperature = [0 0 0]; + [BestSys,BestSpc] = esfit('thyme',params.max_mean,Sys0,Vary,Exp,[],FitOpt); + plot(ax,0.1*params.Field_Vector,params.max_mean,'r',... + 0.1*params.Field_Vector,BestSpc,'b','LineWidth',1.2) + xlabel 'Magnetic Field / mT' + ylabel 'EPR signal / A. U.' + legend('experimental','simulation') + axis tight + end + + function SimSaveButtonPushed(src,event) +% Sys = BestSys; end function SimDoneButtonPushed(src,event) close 'Simulation' end - -end - + +end \ No newline at end of file