Remove outlier and fit curve

4 vues (au cours des 30 derniers jours)
Justin Igwe
Justin Igwe le 6 Juin 2016
Modifié(e) : Justin Igwe le 9 Juin 2016
Hi all, I am quite new in the field of programming. I have a set of data with outliers, can someone please suggest a way of removing outliers and make the curve follow a normal trend of values instead of plotting NaN. Please see attached shot.
  3 commentaires
Star Strider
Star Strider le 6 Juin 2016
We also need to see the code you are using to fit your data.
Justin Igwe
Justin Igwe le 9 Juin 2016
Sorry I have just attached the screen shot

Connectez-vous pour commenter.

Réponses (1)

KSSV
KSSV le 9 Juin 2016
From the graph, I understand that, you want to remove the data which is greater then 23 (approximately). So, from the data get the position of values which are greater then 23 (your desired values) and make them NaN.
% Pseudo code
x = 1:100 ;
y = rand(size(x)) ;
idx = y>0.7 ; % Get positions in y which are greater then 0.7 (~23 in your case)
y(idx) = NaN ;
plot(x,y) ;
  1 commentaire
Justin Igwe
Justin Igwe le 9 Juin 2016
Modifié(e) : Justin Igwe le 9 Juin 2016
Hi Dr.Siva, thank you for your help. I actually needed to fill in the range with an estimated value as I do not want to have empty data such as NaN. So I used a code liike this:
clear all
clc
%max_fft_amplitudes_c1 = randn(315,1);
max_fft_amplitudes_c1=linspace(1,20,315);
for a=200:250
max_fft_amplitudes_c1(a)=a/100*max_fft_amplitudes_c1(a);
end
max_fft_amplitudes_c1_clean = max_fft_amplitudes_c1;
figure ('Name','mean_c1 vs mean_c1_clean','NumberTitle' ,'off')
plot (max_fft_amplitudes_c1)
hold on
%go through the whole data and find difference between current data and the
%future data
for b=1:314;
c(b)=abs(max_fft_amplitudes_c1_clean(b) - max_fft_amplitudes_c1_clean(b+1));
if c(b)>0.2
%if this difference is greater than a threshhold, reduce it by adding
%0.06 to the previous data
if b>3
max_fft_amplitudes_c1_clean(b)=max_fft_amplitudes_c1_clean(b-1)+0.06;
end
end
end
plot(c)
plot (max_fft_amplitudes_c1_clean)
legend('max_fft_amplitudes_c1','c','max_fft_amplitudes_c1_clean')

Connectez-vous pour commenter.

Catégories

En savoir plus sur Two y-axis dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by