From: Jonathan on
Hi there,

I'm fitting some data to an equation, which has 3 variables, k1, k2 and tau. I have an estimated value for tau which I have read from the data earlier in the code, which is placed in the variable "tau". I wish to tell the fit function that the starting point for searching for a value of tau is the value within variable "tau". I also want to say that the upper and lower bounds for tau should be 1.25*tau and 0.8* tau respectively.

The fitting works quite well, however it seems that tau is always "fixed at bound", even though it appears (to me!) that it shouldn't be. In other words, suppose Upper and Lower bounds for tau are 3 and 2... Matlab will tell me that tau = 2.5 and is "fixed to bound". To me this seems that I have specifiied the bounds for tau incorrectly, though I don't understand why that would be the case.

Here is my code:

FreqResponse=fittype('k1 -k2* log(1+4*pi^2*x^2*tau_f^2)');


%we fit the data
[fitresult,gof2]=fit(Freq(7:801,:),data_,FreqResponse,'MaxFunEvals',10000,'startpoint',[-27.2, 3.6, tau],'Upper',[inf, inf, 1.25*tau],'Lower',[-inf, -inf, 0.8*tau]);

Any ideas?

Thanks in advance!