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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/249301/Capture.png)
Main things to find here is "node".
I tried polyfit, smoothdata but not able to get it working.
Any suggestions.
댓글 수: 1
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 Center 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!