Filter löschen
Filter löschen

How to change selected data which would give me the line of best fit (R squared close to 1)?

1 Ansicht (letzte 30 Tage)
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)?

Akzeptierte Antwort

Richard Brown
Richard Brown am 4 Jul. 2012
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.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by