1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| clear
Nx=100;
w=ones(Nx,1);
t=linspace(0,35,Nx);%le temps en minutes
%y = Moyenne:% moyenne est une matrice (8401x1)
y= 10*rand(1,Nx)+5;
plot(t,y)
axis([0 35 0 20])
grid
hold on
[P,S] = polyfit(t,y,8);
yf=polyval(P,t);
plot(t,yf,'r')
% Suppression des valeurs de 10 à 12
ym=[y(1:9) y(13:end)];
tm=[t(1:9) t(13:end)];
[Pm,Sm] = polyfit(tm,ym,8);
yfm=polyval(Pm,tm);
plot(tm,yfm,'.k','MarkerSize',13)
%
% Solution avec fit et smoothingspline
Indice_nul=[10:12];
outliers = excludedata(t,y,'indices',Indice_nul);
f=fit(t',y','smoothingspline','Exclude',outliers);
hm=plot(f,t,y)
set(hm,'Color','g','LineWidth',2) |
Partager