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!