title: Cartesian to Spherical coordinate conversion specific case when Φ is zero and θ is indeterminant, Phase unwrapping
body: <p>Following is the conversion for spherical to cartesian coordinate</p>
  
  <pre><code>X = r cosθ sinΦ 
  Y = r sinθ sinΦ 
  Z = rcosΦ
  </code></pre>
  
  <p>we are using the reverse computation to compute spherical coordinate from cartesian coordinate which is defined as</p>
  
  <pre><code>r = √(x^2+y^2+z^2 ) 
  θ = atan⁡(Y./X) 
  Φ = atan⁡(√(X^2+Y^2 )./Z)
  </code></pre>
  
  <p>The problem arises when Y and X are zero so θ can take any arbitrary value so during Matlab computations this results in NAN(not a number ) which makes θ discontinuous. Is there any interpolation technique to remove this discontinuity and how to interpret θ in this case.</p>
  
  <p>θ is a matrix at various point and it gives following result it has jumps and black patched that represent discontinuity whereas I need to generate the following image with smooth variation. Please see the obtained theta and correct theta variation by clicking on the link and suggest some changes.
   <a href="http://i.stack.imgur.com/LYHvv.png" rel="nofollow">Discontinuous_Theta_variation</a>
  <a href="http://i.stack.imgur.com/1Ky4x.png" rel="nofollow">Correct Theta variation</a></p>