# MATLAB: Best fit line in polarscatter graph??

polarscatter

hey everyone. New to matlab and I generated a two series polar plot. Is is possible to find a best fit line for a data in polar plot???? below is the data for one of the sets. Now, it it possible to get a best fit line? Please and thank you.
>>theta =
   -1.0288   -1.2100   -1.2939   -1.2154   -1.1319   -1.0932   -0.9575   -1.0157   -1.0940   -1.1195   -1.2772   -1.3624
>>rho =
    4.4195    5.6823    7.0426    7.1330    9.2521   11.1276   12.4041   12.0159   15.0591   20.9700   23.3849   26.4164>>polarscatter (theta, rho)>>ax=gca>>ax. ThetaZeroLocation = 'left'

•  % change polar to Cartesian   [x,y] = pol2cart(theta,rho) ;  %%fit line in Cartesian coordinates  P = polyfit(x,y,1);  yfit = P(1)*x+P(2);  figure  plot(x,y,'.r')  hold on;  plot(x,yfit,'b');  %%Change fit coordinates to polar  [thetafit,rhofit] = cart2pol(x,yfit) ;  figure  polarscatter (theta, rho) ;  ax=gca ;  ax. ThetaZeroLocation = 'left' ;  hold on  polarscatter (thetafit, rhofit,'r') ;