Fit my Data to a pattern with some unknown parameters

2 次查看(过去 30 天)
Hi,
I have a array with some noise and want to correct it to a know pattern (line-like).
Here is an example:
% type-1
my_array1 = [1,2,3,4,5,6,7,8,9,10,11,...
12,13,14,15,16,17,18,19,20,21,22,...
23,23,22,21,20,19,19,17,16,16,14,14,...
35,10,10,9,8,40,41,42,43,44,45,46,...
1,2,3,4,5,6,7,8,9,10,11,12,13,14];
% type-2
my_array2 = [1,2,3,4,5,6,7,8,9,10,11,...
12,13,14,15,16,17,18,19,20,21,22,...
22,22,22,21,20,19,19,17,16,16,14,14,...
35,10,10,9,8,40,41,42,43,44,45,46,...
1,2,3,4,5,6,7,8,9,10,11,12,13,14];
my_arr_len = length(my_array1);
node = 23; % not known - needed to find
pattern = [1:node,node:-1:1];
len_pattern = length(pattern);
rem_len = my_arr_len - len_pattern;
pattern = [pattern, 1:rem_len];
figure,
subplot(121), plot(my_array1,'r')
hold on, plot(pattern, 'g--'), hold off
title('type 1')
subplot(122), plot(my_array2,'b')
hold on, plot(pattern, 'g--'), hold off
title('type 2')
Capture.PNG
Main things to find here is "node".
I tried polyfit, smoothdata but not able to get it working.
Any suggestions.
  1 个评论
dpb
dpb 2019-11-20
Looks like piecewise linear fit first then remove outliers and refit iteratively.
Or, try to identify the bad sections and remove what you can first that should make the initial fit somewhat closer.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by