Hello everyone
I'm trying to figure out the impact of boundary conditions on a fitting. The file where my fitting is defined looks like:
function [fitresult,gof]=Fitting(space,magnetization,initial_magnetization,initial_conditions)
if round(initial_magnetization(1),1)==0.7 && round(initial_magnetization(end),1)==0.7
fitting_function='(1/sqrt(2))*(sin(atan(exp(Q*(x-x0)/Delta)))+cos(atan(exp(Q*(x-x0)/Delta))))';
elseif round(initial_magnetization(1),1)==-0.7 && round(initial_magnetization(end),1)==-0.7
fitting_function='-(1/sqrt(2))*(sin(atan(exp(Q*(x-x0)/Delta)))+cos(atan(exp(Q*(x-x0)/Delta))))';
elseif round(initial_magnetization(1),1)==-0.7 && round(initial_magnetization(end),1)==0.7
fitting_function='(1/sqrt(2))*(sin(atan(exp(Q*(x-x0)/Delta)))-cos(atan(exp(Q*(x-x0)/Delta))))';
elseif round(initial_magnetization(1),1)==0.7 && round(initial_magnetization(end),1)==-0.7
fitting_function='-(1/sqrt(2))*(sin(atan(exp(Q*(x-x0)/Delta)))-cos(atan(exp(Q*(x-x0)/Delta))))';
ft=fittype(fitting_function,'independent','x','dependent','y');
opts=fitoptions('Method','NonlinearLeastSquares');
opts.StartPoint=initial_conditions;
[fitresult,gof]=fit(space,magnetization,ft,opts);
On the other hand, in the file where I process the data I have the following:
Initial_Conditions=[Delta0 x0_Q Topological_Charge(1)];
[fitresult,gof]=Fitting(Spatial_Grid,mx(:,j),mx(:,1),Initial_Conditions);
Delta_Q(j)=fitresult.Delta;
Initial_Conditions=[Delta_Q(j) x0_Q(j) Topological_Charge(j)];
I was wondering on which order I have to write the initial conditions (Delta0, x0_Q, Topological_Charge), to match what it is defined in the function Fitting. It is important to note that Delta0/Delta_Q corresponds to Delta, x0_Q to x0, and Topological_Charge to Q in the fitting function environment. That is, as, for example:
Initial_Conditions=[Delta_Q(j) x0_Q(j) Topological_Charge(j)];
Initial_Conditions=[x0_Q(j) Delta_Q(j) Topological_Charge(j)];