title: How can I fit a cosine function?
body: <p>I wrote a python function to get the parameters of the following cosine function:
  <img src="https://i.stack.imgur.com/1St1m.png" alt="enter image description here"></p>
  
  <pre><code>param = Parameters()    
  param.add( 'amp', value = amp_guess, min = 0.1 * amp_guess, max = amp_guess )
  
  param.add( 'off', value = off_guess, min = -10, max = 10 )
  
  param.add( 'shift', value = shift_guess[0], min = 0, max = 2 * np.pi, )
  
  fit_values = minimize( self.residual, param, args = ( azi_unique, los_unique ) )
  
  def residual( self, param, azi, data ):
          """
          Parameters
          ----------
  
          Returns
          -------
          """
          amp = param['amp'].value
          off = param['off'].value
          shift = param['shift'].value
          model = off + amp * np.cos( azi - shift )
          return model - data
  </code></pre>
  
  <p>In Matlab how can get the amplitude, offset and shift of the cosine function?</p>