필터 지우기
필터 지우기

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)?

채택된 답변

Richard Brown
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개)

카테고리

Help CenterFile 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!

Translated by