Non Linear Least Square fitting for large data

1 view (last 30 days)
Dear all,
I would like to do least square fitting for a data I get from an antenna. The data looks like this Data plot. I tried using this function in Matlab to fit the data and I used a polynomial of 7 degree, but the fitting wasn't appropriate. People suggested that using a polynomial of a higher degree than 7 is not a good idea.
function leastCurvePolynomialFit(x,y, n)
p = polyfit(x, y, n)
poly_line = polyval(p, x);
%Plot data and estimated polynomial
figure
hold all
plot(x,y,'+')
plot(x,poly_line)
xlabel('X')
ylabel('Y')
title('Noisy Data and Fitted Line')
box
end
If anyone can help me solve this problem without toolbox I will really appreciate it because I don't have any extra toolbox from Matlab and I would like to convert the code to C++ eventually.
Many thanks
  1 Comment
Star Strider
Star Strider on 7 Jan 2015
Do you have a mathematical model of the radiation pattern of your antenna? If so, use the nlinfit and nlpredci (Statistics Toolbox) functions to fit your data to it and estimate the prediction errors. Use the prediction errors to eliminate outliers.

Sign in to comment.

Answers (1)

dpb
dpb on 6 Jan 2015
doc spline % and friends
Knowing the end purpose of the fitted line may be of some help in refining a response.
  1 Comment
ADASI
ADASI on 7 Jan 2015
This data is in the form (X,Y) where X represent an angle from -180,+180 and Y represent the signal strength that I get from my antenna.I need to do a non linear least curve fitting to remove any outliers from the data.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!