title: curve fitting estimate parameter - inverse square law
body: <p>I want to make a plot force vs position (for coulomb's law) and estimate the constant e0.
  I have the values of charges , q1=1,q2=1.
  I have for example the  </p>
  
  <pre><code>position=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1];
  
  force=[0.08,0.015,0.013,0.0062,0.0016,0.00519,-0.00159,0.00118,...
      0.0061,0.00155,0.00143];
  </code></pre>
  
  <p>Coulomb is F= (1/4*pi*e0) * q1*q2/r^2.
  So, it is in the form:</p>
  
  <p>y=ax^-m  , where a= (q1*q2/4*pi*e0)</p>
  
  <p>I am doing:</p>
  
  <pre><code>p=polyfit(-log10(position),log10(force),1);  % I am not sure about  '1' and minus
  
  m=p(1);
  a=10^(p(2)); % I am not sure about a 
  
  
  
  xp=0.1:0.1:1.1;
  yp=a*xp.^(-m);
  
  
  plot(position,force,'o',xp,yp)
  
  e0=q1*q2/4*pi*a
  </code></pre>
  
  <p>I am not finding a right value for e0.Am I doing something wrong?
  The m value should be -2 but I am taking :</p>
  
  <blockquote>
    <p>m =</p>
    
    <p>1.6287 - 0.2008i</p>
  </blockquote>