Non Linear Least Square fitting for large data
显示 更早的评论
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 个评论
Star Strider
2015-1-7
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.
回答(1 个)
dpb
2015-1-6
doc spline % and friends
Knowing the end purpose of the fitted line may be of some help in refining a response.
类别
在 帮助中心 和 File Exchange 中查找有关 Linear Predictive Coding 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!