implemented "Saving parameters" feature
This commit is contained in:
parent
2aaf290295
commit
4be4569f50
@ -1,8 +1,19 @@
|
||||
function [params] = simulation_TREPR(Exp,Sys0,params)
|
||||
function [params] = simulation_TREPR(params)
|
||||
%SIMULATION_TREPR Summary of this function goes here
|
||||
%
|
||||
% Detailed explanation goes here
|
||||
|
||||
%% setup
|
||||
%create struct for passing data between callbacks
|
||||
eventdata.manSys = params.Manual_Sys;
|
||||
eventdata.manExp.mwFreq = params.mwFreq; %GHz
|
||||
eventdata.manExp.nPoints= length(params.Field_Vector);
|
||||
eventdata.manExp.CenterSweep = 0.1*[params.Field_Center params.Field_Sweep]; % mT (converted from Gauss)
|
||||
eventdata.manExp.Harmonic = 0; % zeroth harmonic
|
||||
eventdata.manExp.Temperature = params.Triplett_pop;
|
||||
eventdata.simSys = params.Manual_Sys; %initialize simulation parameters
|
||||
eventdata.simExp = eventdata.manExp;
|
||||
|
||||
%% creating UI
|
||||
fig = figure;
|
||||
fig.Name = 'Simulation';
|
||||
@ -19,7 +30,7 @@ ax = axes(plotpanel);
|
||||
ax.XLabel.String = 'magnetic field';
|
||||
ax.YLabel.String = 'Intensity';
|
||||
%plot manual simulation
|
||||
[bfield,spec] = pepper(Sys0,Exp);
|
||||
[bfield,spec] = pepper(eventdata.manSys,eventdata.manExp);
|
||||
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)
|
||||
@ -286,7 +297,7 @@ uicontrol(InpTx); %passes focus to first input
|
||||
uiwait(fig)
|
||||
|
||||
%% Callback functions
|
||||
function BestSys = SimStartButtonPushed(src,event)
|
||||
function SimStartButtonPushed(src,event)
|
||||
%get Vary and Opt from Input
|
||||
varT1 = str2double(get(InpTx,'String'));
|
||||
varT2 = str2double(get(InpTy,'String'));
|
||||
@ -301,19 +312,31 @@ uiwait(fig)
|
||||
Vary.g = str2double(get(InpG,'String'));
|
||||
FitOpt.Method = get(InpMeth,'String');
|
||||
FitOpt.Scaling = get(InpScal,'String');
|
||||
%get previous simulation parameters (manual or saved)
|
||||
Sys0 = eventdata.simSys;
|
||||
Exp0 = eventdata.simExp;
|
||||
%perform fit
|
||||
Sys0.Temperature = [0 0 0];
|
||||
[BestSys,BestSpc] = esfit('thyme',params.max_mean,Sys0,Vary,Exp,[],FitOpt);
|
||||
[BestSys,BestSpc] = esfit('thyme',params.max_mean,Sys0,Vary,Exp0,[],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
|
||||
%normalize Triplett population
|
||||
Tsum = sum(BestSys.Temperature);
|
||||
BestSys.Temperature = BestSys.Temperature ./ Tsum;
|
||||
%write best simulation parameters to eventdata
|
||||
eventdata.BestSys = BestSys;
|
||||
end
|
||||
|
||||
function SimSaveButtonPushed(src,event)
|
||||
% Sys = BestSys;
|
||||
%set current parameters as new start values
|
||||
eventdata.simSys = eventdata.BestSys;
|
||||
eventdata.simExp.Temperature = eventdata.BestSys.Temperature;
|
||||
%save fitted parameters to struct
|
||||
params.Fitted_Simulation = eventdata.BestSys;
|
||||
end
|
||||
|
||||
function SimDoneButtonPushed(src,event)
|
||||
|
Loading…
x
Reference in New Issue
Block a user