I have the following data:
eR = {1.1*10^-4 , 3.3*10^-4 , 1.1*10^-3 , 2*10^-3 ,
3.3*10^-3 , 5.8*10^-3 , 1.1*10^-2 , 1.9*10^-2 , 3.3*10^-2 ,
5.8*10^-2 , 1.1*10^-1} ;
NoDF = {2 , 2 , 2 , 3 , 4 , 4 , 7 , 11 , 18 , 21 , 35};
DSF = Transpose@{eR , NoDF};
Now, what I would like to do is to linearly fit a curve on the above set of points. Thus, I use the following
fitF = FindFit[DSF, a*n^b, {a, b}, n];
So, when I plot the data and the curve together they look ok. First I plot the data point
plot1F = {DSF } //
ListLogLogPlot[#, Joined -> False, FrameTicks -> All ,
Frame -> True] &
Secondly, I plot the fitting curve
a = Last[First[fitF]];
b = Last[Last[fitF]];
func[x_] := a x^b;
Data = Table[func[x] , {x , 1.1*10^-4 , 1.1*10^-1 , 0.00001}];
XF = Table[x , {x , 1.1*10^-4 , 1.1*10^-1 , 0.00001}];
DATAfit = Transpose@{XF , Data};
plot2F = {DATAfit} //
ListLogLogPlot[# , PlotRange -> All , FrameTicks -> All,
Frame -> True] &
Then, I put them together
Show[plot1F , plot2F , PlotRange -> All]
The result looks ok for me. But then I was asked to change the function and first, take the logarithm of the points and then fit them with a + b*x function. So first I took the logarithm of the data point
DSFL = Transpose@{Log[eR] , Log[NoDF]};
and then fit the data
fitF2 = FindFit[DSFL, c + d n, {c, d}, n];
c = Last[First[fitF2]];
d = Last[Last[fitF2]];
funcL[x_] := c + d x;
But when I plot the data, it seems that there is something wrong with my plots. Because the curve does not fit the data
DataL = Table[funcL[x] , {x , 1.1*10^-4 , 1.1*10^-1 , 0.00001}];
XF = Table[x , {x , 1.1*10^-4 , 1.1*10^-1 , 0.00001}];
DATAL = Transpose@{XF , DataL};
plot3F = {DATAL} //
ListPlot[# , PlotRange -> All , FrameTicks -> All, Frame -> True] &
Show[plot1F , plot3F , PlotRange -> All]
Now, I want to know if there is something wrong with my function or code. Because I know that the method is correct and I should be able to fit the data with a c + d*x function.