Chapters:
|
MuSR /
MulabAddAComponent< How to install mulab | Index | Finer points about fit components > Sequential steps to introduce a new function in 1.05Suppose you want to add a function mydecay 1) Edit mu_initialize_models Go to the bottom and copy the last block of the structure changing it according to this MU_COMPONENT.NAME(9)={'md'}; % a unique two letter acronym MU_COMPONENT.PARAMETER(9).NUMBER=4; % number of parameters MU_COMPONENT.PARAMETER(9).NAME={'Amp','Gau','DeL','DeLo'}; % their names MU_COMPONENT.PARAMETER(9).STEPBOUNDS=[0.01 0 0;... 0.1 0 0; 0.1 1e-3 1e3; 0.1 0 0]; % initial step lo bound hi bound % 0.1 0 0 means step=0.1, lo bound=-inf, hi bound=+inf % 0.1 0 1e4 means step=0.1, lo bound=0, hi bound=10000 MU_COMPONENT.DEFINITION(9)={'mydecay(p,data)'}; % change function name but keep the argument list MU_COMPONENT.HELP(9)={['My decay' ... 'static in zero or longitudinal field, with T1']} ; % short description 2) Write the function f=mydecay(p,data) in the file Debugging: temporarily place a copy of the new Sequential steps to introduce a new function in 1.04(obsolete, install 1.05 instead) Suppose you want to add the function mydecay.m First edit mu_initialize_models Go to the bottom and copy the last block of the structure MU_COMPONENT.NAME(9)={'md'}; % a new two letter acronym MU_COMPONENT.PARAMETER(9).NUMBER=4; % number of parameters MU_COMPONENT.PARAMETER(9).NAME={'Amp','Gau','DeL','DeLo'}; MU_COMPONENT.PARAMETER(9).TYPE={'unlim','unlim','positive','unlim'}; MU_COMPONENT.DEFINITION(9)={'mydecay(p,data)'}; %change name and keep the argument list MU_COMPONENT.HELP(9)={['My decay' ... 'static in zero or longitudinal field, with T1']} ; % description Parameter name convention. The name defines the bounds and the initial step size\\ (or initial error). This is a list of already defined parameters Amp unlimited partial asymmetry Gau unlimited field (G) LFG positive def field (G) Hypf unlimited hyperfine frequency (MHz) Phi unlimited phase (deg) DeLo unlimited rate, Lorentian (us^-1) DeGa unlimited rate, Gaussian (us^-1) DeL positive defined rate (us^-1) DeG positive defined rate (us^-1) DeCR positive defined rate for stretched (us^-1) Write the function f=mydecay(p,data): If you need a new type of parameter, give it a new name\\
and define their initial step size and bounds in routine mupar.m
Look at the end of the mupar function, where it defined steps and bounds\\
within the switch char(lower(parname)) % implies unique names for each % type of parameter case {'lpha','amp'} error=0.01; % asymmetry etc... For instance if your new parameter Myp must be limited within 1e-3 and 1e3, with initial step 0.01, add case{'myp} % the list is translated to lowercase error=0.01; lowbnd=1e-3; highbnd=1000; If you do not add the second two lines Myp will be unbounded (lowbnd, highbnd= 0,0) When you are done, make sure the new .m files are in the toolbox and restart matlab (if you work in debugging mode you might be able to substitute the files without restarting matlab) All the routines dealing with model components
component name (two character codename, e,g. da, ba, mu ...)
parameters number (how many paramenters)
parameters names (e.g. Amp, Gau, DeLo, etc.)
parameters type (unlim positive etc - unused) % in 1.04
parameters steps and bounds ([0.01 0 0; 0.1 0 0; 0.01 0 0]) % in 1.05
calling string (either the command or the function call, e.g. {'myfunct(p,data)'};)
help string (used by
< How to install mulab | Index | Finer points about fit components > |