Finished objectifying #8
| @ -1,7 +1,296 @@ | ||||
| function [outputArg1,outputArg2] = simulation_TREPR(inputArg1,inputArg2) | ||||
| function [params] = simulation_TREPR(Exp,Sys,params) | ||||
| %SIMULATION_TREPR Summary of this function goes here | ||||
| % | ||||
| %   Detailed explanation goes here | ||||
| outputArg1 = inputArg1; | ||||
| outputArg2 = inputArg2; | ||||
| 
 | ||||
| %% creating UI | ||||
| fig = figure; | ||||
| fig.Name = 'Simulation'; | ||||
| fig.Units = 'Normalized'; | ||||
| fig.Position = [.15 .2 .7 .6]; | ||||
| fig.Tag = 'Normalize'; | ||||
| 
 | ||||
| %panel for plot | ||||
| plotpanel = uipanel(fig); | ||||
| plotpanel.Units = 'Normalized'; | ||||
| plotpanel.Position = [.01 .01 .7 .98]; | ||||
| %axes for plot | ||||
| ax = axes(plotpanel); | ||||
| ax.XLabel.String = 'magnetic field'; | ||||
| ax.YLabel.String = 'Intensity'; | ||||
| %plot manual simulation | ||||
| [bfield,spec] = pepper(Sys,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) | ||||
| legend('experimental','simulation') | ||||
| axis tight | ||||
| 
 | ||||
| %% create push buttons | ||||
| s = uicontrol(fig,'Style','pushbutton'); | ||||
| s.String = 'Start Fit'; | ||||
| s.Units = 'Normalized'; | ||||
| s.Position = [.72 .13 .27 .05]; | ||||
| s.FontUnits = 'Normalized'; | ||||
| s.FontSize = 0.6; | ||||
| s.Tag = 'Start'; | ||||
| s.Callback = @SimStartButtonPushed; | ||||
| 
 | ||||
| p = uicontrol(fig,'Style','pushbutton'); | ||||
| p.String = 'Save Parameters'; | ||||
| p.Units = 'Normalized'; | ||||
| p.Position = [.72 .07 .27 .05]; | ||||
| p.FontUnits = 'Normalized'; | ||||
| p.FontSize = 0.6; | ||||
| p.Tag = 'Save'; | ||||
| p.Callback = @SimSaveButtonPushed; | ||||
| 
 | ||||
| d = uicontrol(fig,'Style','pushbutton'); | ||||
| d.String = 'Done'; | ||||
| d.Units = 'Normalized'; | ||||
| d.Position = [.72 .01 .27 .05]; | ||||
| d.FontUnits = 'Normalized'; | ||||
| d.FontSize = 0.6; | ||||
| d.Tag = 'Done'; | ||||
| d.Callback = @SimDoneButtonPushed; | ||||
| 
 | ||||
| %% create input and text fields (Triplet) | ||||
| textTrip = uicontrol(fig,'Style','text'); | ||||
| textTrip.String = 'Triplett population variations'; | ||||
| textTrip.Units = 'Normalized'; | ||||
| textTrip.Position = [.71 .94 .28 .05]; | ||||
| textTrip.HorizontalAlignment = 'center'; | ||||
| textTrip.FontUnits = 'Normalized'; | ||||
| textTrip.FontSize = 0.6; | ||||
| textTrip.FontWeight = 'bold'; | ||||
| textTrip.Tag = 'textTrip'; | ||||
| 
 | ||||
| textTx = uicontrol(fig,'Style','text'); | ||||
| textTx.String = 'T_1 = '; | ||||
| textTx.Units = 'Normalized'; | ||||
| textTx.Position = [.71 .89 .04333 .05]; | ||||
| textTx.HorizontalAlignment = 'right'; | ||||
| textTx.FontUnits = 'Normalized'; | ||||
| textTx.FontSize = 0.6; | ||||
| textTx.Tag = 'textTx'; | ||||
| 
 | ||||
| InpTx = uicontrol(fig,'Style','edit'); | ||||
| InpTx.String = '0'; | ||||
| InpTx.Units = 'Normalized'; | ||||
| InpTx.Position = [.75334 .89 .04333 .05]; | ||||
| InpTx.HorizontalAlignment = 'left'; | ||||
| InpTx.FontUnits = 'Normalized'; | ||||
| InpTx.FontSize = 0.6; | ||||
| InpTx.Tag = 'InpTx'; | ||||
| 
 | ||||
| textTy = uicontrol(fig,'Style','text'); | ||||
| textTy.String = 'T_2 = '; | ||||
| textTy.Units = 'Normalized'; | ||||
| textTy.Position = [.80668 .89 .04333 .05]; | ||||
| textTy.HorizontalAlignment = 'right'; | ||||
| textTy.FontUnits = 'Normalized'; | ||||
| textTy.FontSize = 0.6; | ||||
| textTy.Tag = 'textTy'; | ||||
| 
 | ||||
| InpTy = uicontrol(fig,'Style','edit'); | ||||
| InpTy.String = '0'; | ||||
| InpTy.Units = 'Normalized'; | ||||
| InpTy.Position = [.85001 .89 .04333 .05]; | ||||
| InpTy.HorizontalAlignment = 'left'; | ||||
| InpTy.FontUnits = 'Normalized'; | ||||
| InpTy.FontSize = 0.6; | ||||
| InpTy.Tag = 'InpTy'; | ||||
| 
 | ||||
| textTz = uicontrol(fig,'Style','text'); | ||||
| textTz.String = 'T_3 = '; | ||||
| textTz.Units = 'Normalized'; | ||||
| textTz.Position = [.90334 .89 .04333 .05]; | ||||
| textTz.HorizontalAlignment = 'right'; | ||||
| textTz.FontUnits = 'Normalized'; | ||||
| textTz.FontSize = 0.6; | ||||
| textTz.Tag = 'textTz'; | ||||
| 
 | ||||
| InpTz = uicontrol(fig,'Style','edit'); | ||||
| InpTz.String = '0'; | ||||
| InpTz.Units = 'Normalized'; | ||||
| InpTz.Position = [.94667 .89 .04333 .05]; | ||||
| InpTz.HorizontalAlignment = 'left'; | ||||
| InpTz.FontUnits = 'Normalized'; | ||||
| InpTz.FontSize = 0.6; | ||||
| InpTz.Tag = 'InpTz'; | ||||
| 
 | ||||
| %% create input and text fields (D & E) | ||||
| textDE = uicontrol(fig,'Style','text'); | ||||
| textDE.String = 'D tensor variation'; | ||||
| textDE.Units = 'Normalized'; | ||||
| textDE.Position = [.71 .78 .28 .05]; | ||||
| textDE.HorizontalAlignment = 'center'; | ||||
| textDE.FontUnits = 'Normalized'; | ||||
| textDE.FontSize = 0.6; | ||||
| textDE.FontWeight = 'bold'; | ||||
| textDE.Tag = 'textDE'; | ||||
| 
 | ||||
| textD = uicontrol(fig,'Style','text'); | ||||
| textD.String = 'D = '; | ||||
| textD.Units = 'Normalized'; | ||||
| textD.Position = [.71 .73 .0675 .05]; | ||||
| textD.HorizontalAlignment = 'right'; | ||||
| textD.FontUnits = 'Normalized'; | ||||
| textD.FontSize = 0.6; | ||||
| textD.Tag = 'textD'; | ||||
| 
 | ||||
| InpD = uicontrol(fig,'Style','edit'); | ||||
| InpD.String = '100'; | ||||
| InpD.Units = 'Normalized'; | ||||
| InpD.Position = [.7775 .73 .0675 .05]; | ||||
| InpD.HorizontalAlignment = 'left'; | ||||
| InpD.FontUnits = 'Normalized'; | ||||
| InpD.FontSize = 0.6; | ||||
| InpD.Tag = 'InpD'; | ||||
| 
 | ||||
| textE = uicontrol(fig,'Style','text'); | ||||
| textE.String = 'E = '; | ||||
| textE.Units = 'Normalized'; | ||||
| textE.Position = [.855 .73 .0675 .05]; | ||||
| textE.HorizontalAlignment = 'right'; | ||||
| textE.FontUnits = 'Normalized'; | ||||
| textE.FontSize = 0.6; | ||||
| textE.Tag = 'textE'; | ||||
| 
 | ||||
| InpE = uicontrol(fig,'Style','edit'); | ||||
| InpE.String = '20'; | ||||
| InpE.Units = 'Normalized'; | ||||
| InpE.Position = [.9225 .73 .0675 .05]; | ||||
| InpE.HorizontalAlignment = 'left'; | ||||
| InpE.FontUnits = 'Normalized'; | ||||
| InpE.FontSize = 0.6; | ||||
| InpE.Tag = 'InpE'; | ||||
| 
 | ||||
| %% create input and text fields (linewidth) | ||||
| textLW = uicontrol(fig,'Style','text'); | ||||
| textLW.String = 'Linewidth variations'; | ||||
| textLW.Units = 'Normalized'; | ||||
| textLW.Position = [.71 .62 .28 .05]; | ||||
| textLW.HorizontalAlignment = 'center'; | ||||
| textLW.FontUnits = 'Normalized'; | ||||
| textLW.FontSize = 0.6; | ||||
| textLW.FontWeight = 'bold'; | ||||
| textLW.Tag = 'textLW'; | ||||
| 
 | ||||
| textGauss = uicontrol(fig,'Style','text'); | ||||
| textGauss.String = 'lw(Gau) = '; | ||||
| textGauss.Units = 'Normalized'; | ||||
| textGauss.Position = [.71 .57 .0675 .05]; | ||||
| textGauss.HorizontalAlignment = 'right'; | ||||
| textGauss.FontUnits = 'Normalized'; | ||||
| textGauss.FontSize = 0.6; | ||||
| textGauss.Tag = 'textGauss'; | ||||
| 
 | ||||
| InpGauss = uicontrol(fig,'Style','edit'); | ||||
| InpGauss.String = '1'; | ||||
| InpGauss.Units = 'Normalized'; | ||||
| InpGauss.Position = [.7775 .57 .0675 .05]; | ||||
| InpGauss.HorizontalAlignment = 'left'; | ||||
| InpGauss.FontUnits = 'Normalized'; | ||||
| InpGauss.FontSize = 0.6; | ||||
| InpGauss.Tag = 'InpGauss'; | ||||
| 
 | ||||
| textLor = uicontrol(fig,'Style','text'); | ||||
| textLor.String = 'lw(Lor) = '; | ||||
| textLor.Units = 'Normalized'; | ||||
| textLor.Position = [.855 .57 .0675 .05]; | ||||
| textLor.HorizontalAlignment = 'right'; | ||||
| textLor.FontUnits = 'Normalized'; | ||||
| textLor.FontSize = 0.6; | ||||
| textLor.Tag = 'textLor'; | ||||
| 
 | ||||
| InpLor = uicontrol(fig,'Style','edit'); | ||||
| InpLor.String = '0'; | ||||
| InpLor.Units = 'Normalized'; | ||||
| InpLor.Position = [.9225 .57 .0675 .05]; | ||||
| InpLor.HorizontalAlignment = 'left'; | ||||
| InpLor.FontUnits = 'Normalized'; | ||||
| InpLor.FontSize = 0.6; | ||||
| InpLor.Tag = 'InpLor'; | ||||
| 
 | ||||
| %% create input and text fields (g) | ||||
| textG = uicontrol(fig,'Style','text'); | ||||
| textG.String = 'g-value variation = '; | ||||
| textG.Units = 'Normalized'; | ||||
| textG.Position = [.71 .46 .2 .05]; | ||||
| textG.HorizontalAlignment = 'right'; | ||||
| textG.FontUnits = 'Normalized'; | ||||
| textG.FontSize = 0.6; | ||||
| textG.Tag = 'textG'; | ||||
| 
 | ||||
| InpG = uicontrol(fig,'Style','edit'); | ||||
| InpG.String = '0.01'; | ||||
| InpG.Units = 'Normalized'; | ||||
| InpG.Position = [.9225 .46 .0675 .05]; | ||||
| InpG.HorizontalAlignment = 'left'; | ||||
| InpG.FontUnits = 'Normalized'; | ||||
| InpG.FontSize = 0.6; | ||||
| InpG.Tag = 'InpG'; | ||||
| 
 | ||||
| %% create input and text fields (FitOpt) | ||||
| textOpt = uicontrol(fig,'Style','text'); | ||||
| textOpt.String = 'Fitting Options'; | ||||
| textOpt.Units = 'Normalized'; | ||||
| textOpt.Position = [.71 .35 .28 .05]; | ||||
| textOpt.HorizontalAlignment = 'center'; | ||||
| textOpt.FontUnits = 'Normalized'; | ||||
| textOpt.FontSize = 0.6; | ||||
| textOpt.FontWeight = 'bold'; | ||||
| textOpt.Tag = 'textFitOpt'; | ||||
| 
 | ||||
| textMeth = uicontrol(fig,'Style','text'); | ||||
| textMeth.String = 'Method: '; | ||||
| textMeth.Units = 'Normalized'; | ||||
| textMeth.Position = [.71 .30 .0675 .05]; | ||||
| textMeth.HorizontalAlignment = 'right'; | ||||
| textMeth.FontUnits = 'Normalized'; | ||||
| textMeth.FontSize = 0.6; | ||||
| textMeth.Tag = 'textMeth'; | ||||
| 
 | ||||
| InpMeth = uicontrol(fig,'Style','edit'); | ||||
| InpMeth.String = 'simplex fcn'; | ||||
| InpMeth.Units = 'Normalized'; | ||||
| InpMeth.Position = [.7775 .30 .2125 .05]; | ||||
| InpMeth.HorizontalAlignment = 'left'; | ||||
| InpMeth.FontUnits = 'Normalized'; | ||||
| InpMeth.FontSize = 0.6; | ||||
| InpMeth.Tag = 'InpMeth'; | ||||
| 
 | ||||
| textScal = uicontrol(fig,'Style','text'); | ||||
| textScal.String = 'Scaling: '; | ||||
| textScal.Units = 'Normalized'; | ||||
| textScal.Position = [.71 .24 .0675 .05]; | ||||
| textScal.HorizontalAlignment = 'right'; | ||||
| textScal.FontUnits = 'Normalized'; | ||||
| textScal.FontSize = 0.6; | ||||
| textScal.Tag = 'textScal'; | ||||
| 
 | ||||
| InpScal = uicontrol(fig,'Style','edit'); | ||||
| InpScal.String = 'lsq'; | ||||
| InpScal.Units = 'Normalized'; | ||||
| InpScal.Position = [.7775 .24 .2125 .05]; | ||||
| InpScal.HorizontalAlignment = 'left'; | ||||
| InpScal.FontUnits = 'Normalized'; | ||||
| InpScal.FontSize = 0.6; | ||||
| InpScal.Tag = 'InpScal'; | ||||
| 
 | ||||
| %% UI wait | ||||
| uicontrol(InpTx); %passes focus to first input | ||||
| uiwait(fig) | ||||
| 
 | ||||
| %% Callback functions | ||||
|     function SimStartButtonPushed(src,event) | ||||
|          | ||||
|     end | ||||
|      | ||||
|     function SimDoneButtonPushed(src,event) | ||||
|         close 'Simulation' | ||||
|     end | ||||
| 
 | ||||
| end | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user