0
$\begingroup$
ks = {0.01, 1, 2, 4, 6, 8, 10, 25, 50, 100, 200, 300, 400, 500, 600, 
   800, 1*^3, 2*^3, 4*^3, 5*^3, 10*^3, 15*^3, 20*^3, 30*^3, 40*^3, 
   70*^3, 1*^5, 1*^6, 1*^8, 1*^12};
aa={15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.708,15.9633,17.5533,18.8007,18.9791,18.9791,18.9791}
ListLogLinearPlot[Table[{ks[[i]], aa[[i]]}, {i, 30}], Joined -> True, 
 PlotRange -> All]

Above are the data I am having, but the problem is my x-axis is in logarithmic scale and my y-axis is in linear scale. Now I have to fit an equation which mimic this curve. I checked NonLinearMoedlFit, But I did not understand it properly. How to extract the equation using the nonlinear model fit function?

$\endgroup$
  • $\begingroup$ Table[{ks[[i]], aa[[i]]}, {i, 30}] can be simplified to Transpose[{ks, aa}] or Thread[{ks, aa}] $\endgroup$ – Bob Hanlon Oct 11 '18 at 17:11
2
$\begingroup$

Very large dynamic ranges with many points crowded together at one end and vast spaces between points at the other end seem to often confuse fit routines. So let's work with the log of your horizontal axis to get the fit and then you can transform that back to your original range afterwards if you really need to.

lst = N[Table[{Log10[ks[[i]]], aa[[i]]}, {i, 30}]];
model = a E^(b (x - c))/(E^(b (x - c)) + 1) + d;
ff = FindFit[lst, model, {a, b, c, d}, x];
Show[ListPlot[lst],Plot[model/.ff, {x,-2,12}], PlotRange->All]

enter image description here

Doesn't look like a bad fit and it didn't need any fiddling or conditions on the variables to get that to work.

And your fitted sigmoid is

18.9969-(3.28698 E^(-13.5137(-4.82318+x)))/(1+E^(-13.5137(-4.82318+x)))
$\endgroup$
  • $\begingroup$ Bill can you explain little extra, I am kind of not understood what you did. I take your answer , thanks. but some information about how you solved help me alot. $\endgroup$ – acoustics Oct 11 '18 at 20:16
  • 1
    $\begingroup$ There are far smaller distances between .01 and 1 and 2 and ... than there are between 1*^6 and 1*^8 and 1*^12. That can confuse Fit. So I used Log10[x] to more evenly space the points and not confuse Fit. Then I picked a Sigmoid function because your plot looked like a Sigmoid. There are lots of those functions, look in Wiki, I just picked one. The parameters determine the lower limit, upper limit, where the "middle" is and how steep it is in the middle. Those are the a,b,c,d that we want Fit to find. Then we give Fit your data, the sigmoid with unknown variables and ask it to find the best. $\endgroup$ – Bill Oct 11 '18 at 20:28
  • 1
    $\begingroup$ Look up each of the functions I used in the help system. And click on the "Details" on each help page to find more information. Study what each function is supposed to do. /. is a function which is also called ReplaceAll. Study it in the help pages. Try to understand why I would use each function where I did. Look at each value I assigned to a variable and try to understand how that value was calculated. If you have more specific questions then please ask. $\endgroup$ – Bill Oct 11 '18 at 20:34
  • $\begingroup$ Bill can we fit the bode plot for only the slope part of the plot. I mean excluding the horizontal line in the plot. $\endgroup$ – acoustics Oct 12 '18 at 7:35
  • 1
    $\begingroup$ You could try fitting a line to the three points that lie on the sharply increasing part of your data. ks = {30*^3, 40*^3, 70*^3}; aa = {15.9633, 17.5533, 18.8007}; lst = N[Table[{Log10[ ks[[i]]], aa[[i]]}, {i, 3}]]; model = m*x + b; ff = FindFit[lst, model, {m, b}, x]; Show[ListPlot[lst], Plot[model /. ff, {x, Log10[30*^3], Log10[70*^3]}], PlotRange -> All] $\endgroup$ – Bill Oct 12 '18 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.