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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
| clear all
scrsz = get(0,'ScreenSize');
%longueur du signal 2mois donc 2*30jours de 24h -1
lend=2*30*24-1;
%echantillonage de 1h
T = 3600;
t=(1:lend-1)*T;tmin=min(t);tmax=max(t);
%Définition des fréquences des signaux
f1=(3*24*3600);
f2=(17*3600);
f3=(12*3600);
%creation des signaux
u1=0.20*sin(2*pi/f1*t);
u2=0.10*sin(2*pi/f2*t);
u3=0.12*sin(2*pi/f3*t);
%signal complet
y1=(u1+u2+u3)';
L = size(y1,1);
%plot des signaux
k=figure('Position',[-1 -80 scrsz(3)/1.2 scrsz(4)])
subplot(4,1,1,'fontsize',16)
plot(t(1:L),u1,'k')
title('u1=0.20*sin(2*pi/f1*t)')
subplot(4,1,2,'fontsize',16)
plot(t(1:L),u2,'k')
title('u2=0.10*sin(2*pi/f2*t)')
subplot(4,1,3,'fontsize',16)
plot(t(1:L),u3,'k')
title('u3=0.12*sin(2*pi/f3*t)')
subplot(4,1,4,'fontsize',16)
plot(t(1:L),y1,'k')
title('u1+u2+u3')
Fs= 1/T;
f1 = Fs/2*linspace(0,1,floor(L/2));
Y1 = fft(y1)/L;
k19=1/(19*3600);
ik19=max(find((f1<k19)));
k15=1/(15*3600);
ik15=max(find((f1<k15)));
%signal complet
r1=real(ifft(Y1)*L);
k=figure('Position',[-1 -80 scrsz(3)/1.2 scrsz(4)])
subplot(3,1,1,'fontsize',12)
plot(f1,2*abs(Y1(1:floor(L/2),: )),'k','linewidth',2)
set(gca,'XScale','log')
xlim([f1(1) f1(floor(L/2))])
legend('Spectre sélectionné')
sb1=subplot(3,1,2,'fontsize',12)
plot(t(1:L),y1,'k','linewidth',2);
hold on
plot(t(1:L),r1','--g','linewidth',2);
xlim([tmin-1 tmax+1])
sb1=subplot(3,1,3,'fontsize',12)
plot(t(1:L),y1,'k','linewidth',2);
hold on
plot(t(1:L),r1','--g','linewidth',2);
legend('signal initial','signal filtré recomposé')
xlim([tmin-1 (tmax+1)/5])
%Filtrage autour de 17h
Y12=Y1;
%je supprime les périodes plus grandes que 19h des deux côtés du spectre
Y12(1:ik19,: )=0;
Y12(end-ik19:end,: )=0;
% je supprime les périodes plus petites que 15h
Y12(ik15:end-ik15,: )=0;
lt1=real(ifft(Y12)*L);
k=figure('Position',[-1 -80 scrsz(3)/1.2 scrsz(4)])
subplot(3,1,1,'fontsize',12)
plot(f1,2*abs(Y12(1:floor(L/2),: )),'k','linewidth',2)
set(gca,'XScale','log')
xlim([f1(1) f1(floor(L/2))])
legend('Spectre sélectionné')
sb1=subplot(3,1,2,'fontsize',12)
plot(t(1:L),u2,'k','linewidth',2);
hold on
plot(t(1:L),lt1','--g','linewidth',2);
xlim([tmin-1 tmax+1])
sb1=subplot(3,1,3,'fontsize',12)
plot(t(1:L),u2,'k','linewidth',2);
hold on
plot(t(1:L),lt1','--g','linewidth',2);
legend('signal initial','signal filtré recomposé')
xlim([tmin-1 (tmax+1)/5]) |
Partager