Fit a curve to a nonlinear 1D data

14 ビュー (過去 30 日間)
Abhishek Singh
Abhishek Singh 2020 年 10 月 4 日
コメント済み: Sindar 2020 年 10 月 5 日
Hello,
I have a monthly rainfall data for a year and it is quadratic with months. I want to get the approximate equation it follows. I tried Excel and other options and the results are also okay but I was thinking if MATLAB could give a more precise equation for me. After that, I will use that equation for another variable. Below is shown the monthly data. I just want to fit a curve to it and get the equation for my further use. Thank you very much.
18.92, 21.6, 27.4, 43.07, 85.66, 230.12, 347.02, 289.74, 197.32, 95.32, 39.5, 19

回答 (1 件)

Sindar
Sindar 2020 年 10 月 4 日
x=1:12;
y=[18.92, 21.6, 27.4, 43.07, 85.66, 230.12, 347.02, 289.74, 197.32, 95.32, 39.5, 19];
% fit to a quadratic (degree 2) polynomial
p = polyfit(x,y,2);
  4 件のコメント
Abhishek Singh
Abhishek Singh 2020 年 10 月 5 日
@Sindar, thank you for commenting and answering. I know that I have mentioned it is quadratic but from the fit graph it looks like more of a polynomial of higher order. So I tried polyfit(x,y,6) and got the values of p. Would you advise any other function than polyfit() to give more precise results with lesser co-efficients in p?
Sindar
Sindar 2020 年 10 月 5 日
what do you mean by "lesser co-efficients in p"?
Also, with only 12 data points, I'd be wary of fitting with high-order polynomials (too many parameters, likely to overfit and result in spikes between sampled points)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by