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
| clear all;close all;clc;
fe=1000;
f1=60;f2=25;f3=10;
T=0.5;
N=fe*T;
t=(0:N-1)/(fe);
% déclaration des signaux:
x1=sin(2*pi*f1*t);
x2=sin(2*pi*f2*t);
x3=sin(2*pi*f3*t);
x=x1+x2+x3;
% Represonttion du signal x(t):
figure
plot(t,x)
grid on
%Représentation des signaux x1(t), x2(t), x3(t):
figure(2)
subplot(311)
plot(t,x1)
grid on
subplot(312)
plot(t,x2)
grid on
subplot(313)
plot(t,x3)
grid on
figure(3)
subplot(311)
plot(t,x)
grid on
% 1- calcul des extremums
% figure(3)
subplot(312)
plot(t,x,'k')
hold on;
[maxim,imax]= findpeaks(x);
plot(t(imax),maxim,'*r');
%
hold on;
y=-x;
[minim,imin]=findpeaks(y);
minim=-minim;
plot(t(imin),minim,'*b')
%
hold off;
grid on
%______________________________________________________
%2 - Cubic Spline Interpolation
subplot(313)
plot(t,x)
%######## Enveloppe supérieure #######
hold on
u =spline(t(imax),maxim);
fnplt(u,'r');
hold on
hold off
%####### Enveloppe inférieure ########
hold on
v =spline(t(imin),minim);
fnplt(v,'g');
hold on
hold off
% 3- Calcul de la moyenne m du signal x
hold on
m=(maxim+minim)/2;
plot(m);
hold off
grid on |
Partager