Effacer les filtres
Effacer les filtres

Fit my Data to a pattern with some unknown parameters

2 vues (au cours des 30 derniers jours)
Gopichandh Danala
Gopichandh Danala le 20 Nov 2019
Commenté : dpb le 20 Nov 2019
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 commentaire
dpb
dpb le 20 Nov 2019
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.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by