2015-04-05 71 views
2

給定以下曲線如何使用Matlab找到含噪數據序列的拐點?

enter image description here

我想確定的x數據點的索引,其中,曲線開始認真地增加(在本例,將是圍繞x = 15)。

雖然我瞭解衍生物可用於確定拐點,但請注意,數據很嘈雜,我不確定該方法能否讓我明確識別「真正的拐點」(本例中x = 15)。

我想知道,如果一個簡單的方法是可行的,如

  • 找到4個數據點,其中x1 < X2 < X3 X4 <
  • 返回X1

的指數你有有關如何完成此任務的任何建議?從上面的曲線

index  SQMean 
_____ ____________ 

'0'  '139.428574' 
'1'  '133.298706' 
'2'  '135.961044' 
'3'  '143.688309' 
'4'  '133.298706' 
'5'  '133.181824' 
'6'  '134.896103' 
'7'  '146.415588' 
'8'  '142.324677' 
'9'  '128.168839' 
'10'  '146.116882' 
'11'  '146.766235' 
'12'  '134.675323' 
'13'  '138.610382' 
'14'  '140.558441' 
'15'  '128.662338' 
'16'  '138.480515' 
'17'  '153.610382' 
'18'  '156.207794' 
'19'  '183.428574' 
'20'  '220.324677' 
'21'  '224.324677' 
'22'  '230.415588' 
'23'  '226.766235' 
'24'  '223.935059' 
'25'  '229.922073' 
'26'  '234.389618' 
'27'  '235.493500' 
'28'  '225.727280' 
'29'  '241.623383' 
'30'  '225.805191' 
'31'  '240.896103' 
'32'  '224.090912' 
'33'  '230.467529' 
'34'  '248.285721' 
'35'  '233.779221' 
'36'  '225.532471' 
'37'  '247.337662' 
'38'  '233.000000' 
'39'  '241.740265' 
'40'  '235.688309' 
'41'  '238.662338' 
'42'  '236.636368' 
'43'  '236.025970' 
'44'  '234.818176' 
'45'  '240.974030' 
'46'  '251.350647' 
'47'  '241.857147' 
'48'  '242.623383' 
'49'  '245.714279' 
'50'  '250.701294' 
'51'  '229.415588' 
'52'  '236.909088' 
'53'  '243.779221' 
'54'  '244.532471' 
'55'  '241.493500' 
'56'  '245.480515' 
'57'  '244.324677' 
'58'  '244.025970' 
'59'  '231.987015' 
'60'  '238.740265' 
'61'  '239.532471' 
'62'  '232.363632' 
'63'  '242.454544' 
'64'  '243.831161' 
'65'  '229.688309' 
'66'  '239.493500' 
'67'  '247.324677' 
'68'  '245.324677' 
'69'  '244.662338' 
'70'  '238.610382' 
'71'  '243.324677' 
'72'  '234.584412' 
'73'  '235.181824' 
'74'  '228.974030' 
'75'  '228.246750' 
'76'  '230.519485' 
'77'  '231.441559' 
'78'  '236.324677' 
'79'  '229.935059' 
'80'  '238.701294' 
'81'  '236.441559' 
'82'  '244.350647' 
'83'  '233.714279' 
'84'  '243.753250' 
+0

爲什麼您將問題標記爲'c'? – chqrlie 2015-04-05 13:56:03

+0

嗨,你可以參考你以前的類似問題,並解釋這與其他問題有何不同。 – 2015-04-05 15:27:23

+1

找到4分並不是很健壯。您可以嘗試對數據進行階梯函數擬合,或者將數值聚類爲較低和較高的值,例如使用kmeans(X,2)',然後使用集羣邊界來查找您的轉換。無論如何,首先使用'smooth'或者'wiener'來平滑數據可能是一個好主意。 – Thomas 2015-04-05 15:27:25

回答

1

的樣本數據如果這是一個一次性的估計,有一兩件事你可以做的是使用從曲線擬合工具箱曲線擬合工具。這裏是我裝了一個分段線性函數,以您的數據爲例:

(點擊圖片爲全尺寸)

該函數的形式

a * (x < b) + c * (x > d) + ((x - b)/(d - b) * (c - a) + a) * (x >= b) * (x <= d) 

它說:有x < b的常數部分,其值爲ax > d的另一個常數部分,值爲c,以及連接它們的線性斜坡。

很難適合這樣的功能,並且只有在您提供體面的開始估計時才能正常工作(請參見截圖中的小窗口)。因此,這不是一種使流程自動化的方法,而只是爲了獲得改進的估算。

在這種情況下,從b = 15擬合的起始估計提供了改進的估計b = 16.58用95%的[15.96, 17.2] -Cl,這表明索引爲0至16屬於初始恆定部分。

曲線擬合工具也可以從GUI規範生成代碼。在這種情況下,結果爲:

[xData, yData] = prepareCurveData(index, SQMean); 

% Set up fittype and options. 
ft = fittype('a * (x < b) + c * (x > d) + ((x - b)/(d - b) * (c - a) + a) * (x >= b) * (x <= d)', 'independent', 'x', 'dependent', 'y'); 
opts = fitoptions(ft); 
opts.Display = 'Off'; 
opts.Lower = [-Inf -Inf -Inf -Inf]; 
opts.StartPoint = [140 15 230 20]; 
opts.Upper = [Inf Inf Inf Inf]; 

% Fit model to data. 
[fitresult, gof] = fit(xData, yData, ft, opts); 

% Plot fit with data. 
figure('Name', 'untitled fit 1'); 
h = plot(fitresult, xData, yData); 
legend(h, 'SQMean vs. index', 'untitled fit 1', 'Location', 'NorthEast'); 
% Label axes 
xlabel('index'); 
ylabel('SQMean'); 
grid on