How to change selected data which would give me the line of best fit (R squared close to 1)?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a range of data
x = -Inf + 0.00000000000000i
-5.94839731081433 + 0.00000000000000i
-4.40441244315510 + 0.00000000000000i
-5.01054824672844 + 0.00000000000000i
-5.79424663098060 + 0.00000000000000i
-4.91523806692085 + 0.00000000000000i
-2.61442132098323 + 3.14159265358979i
-3.99894733505125 + 3.14159265358979i
-2.61265297392781 + 3.14159265358979i
-4.00012588556654 + 0.00000000000000i
-5.20409868989224 + 0.00000000000000i
y = -3.45375423084893
-3.45376083103347
-3.45405094838298
-3.45428146199255
-3.45431857619349
-3.45456107498460
-3.45493413618944
-3.45513888357560
-3.45551262399935
-3.45574790889255
-3.45589974019472
There are 2 things I want to find out.
1. How to set the values of complex numbers in the array x to NaN? 2. How to select the range of data with linear trend and with best fit (R squared close to zero)?
2 件のコメント
Walter Roberson
2012 年 7 月 3 日
Unfortunately, the two things that you want to find out went missing in the Question ?
採用された回答
Richard Brown
2012 年 7 月 4 日
For the first part
x(logical(imag(x))) = nan;
For the second, your data points are all over the show. Any two will fit a straight line pretty well though :)
More seriously, try either a 1-norm best fit, or a method like RANSAC if you know that a subset of the data should fit a line and the rest are outliers.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!