bonjour j'ai un prblm avec mon filtre :

Code:
function solution=DELTA(a,b,c)
%UNTITLED7 Summary of this function goes here
%   Detailed explanation goes here
Delta=b^2-4*a*c;
if Delta==0
    disp("unique solution")
    solution=-b/(2*a)
elseif Delta>0
    disp("deux solutions")
  S1=(-b-sqrt(Delta)/(2*a));
    S2=(-b+sqrt(Delta)/(2*a));
    solution=[S1 S2];
else Delta<0
    disp("pas de solution")
    solution="vide"; 
end

AAAAAAAAAAAAAAAAAAAAAAAAA

S1=xlsread("Signal sinusoidal S1.xlsx");

Temps_1=linspace(0,(length(S1)/1000),length(S1))';

%%% création vecteur temps
Data_S1(:,1)=Temps_1;
Data_S1(:,2)=S1;


%%% filtre low pass 10Hz
d1 = designfilt("lowpassiir",FilterOrder=4, ...
    HalfPowerFrequency=0.015,DesignMethod="butter");
y = filtfilt(d1,Data_S1);

plot(Temps_1,Data_S1(:,2));hold on
plot(Temps_1,y(:,2))
hold off;

%nombre de sinusoides
x=min(y(:,2))
z=max(y(:,2))
for i=1:length(y(:,2));
    if y(:,2)==x;
        C(i,1)=1;
    else y(:,2)==z;
        B(i,1)=1;
    end;
end;

[ind, locs] = findpeaks(-y(:,2));
plot(Temps_1,locs,"-or","LineWidth",2);hold on    
plot(Temps_1,y(:,2),"--b","LineWidth",2)
hold off

% Créez un vecteur de temps (ajustez selon vos besoins)
Temps_1 = linspace(0, length(y(:,2))/1000, length(y(:,2)));

% Plot
figure;
plot(Temps_1, y(:,2), '--b', 'LineWidth', 2); hold on;
plot(Temps_1(locs), y(locs, 2), '-or', 'LineWidth', 2); hold on
plot(Temps_1,Data_S1(:,2),'LineWidth',2)
hold off;
hold off;

AAAAAAAAAAAAAAAAAAAAAAAAAAAA

%%%importation
TD5=xlsread("Signal sinusoidal S1.xlsx");

%%%vecteur temps
Temps=linspace(0,length(TD5)/1000,length(TD5))';

%%%vecteur temps + données
S1(:,1)=Temps;
S1(:,2)=TD5;

%filtre
Wn=2*5/1000;
[a, b]=butter(2,Wn,'low');
filtre=filtfilt(a,b,S1(:, 2));
%%%%%%%%%%%%%%%%%%%%%%%%
figure;
plot(Temps,filtre);hold on;
plot(Temps,S1(:,2));
hold off;


%%% détecter les pics négatifs du signal filtrer
[ind,loc]=findpeaks(filtre);

figure;
plot(Temps(loc),filtre(loc,1),'o','LineWidth',2);hold on;
plot(Temps,filtre,'LineWidth',2);hold on;
plot(Temps,S1(:,2),'LineWidth',2);
hold off;
hold off;

%%%% cycle min/max
Max_Min(1,1)=max(filtre(1:148,1));
Max_Min(1,2)=min(filtre(1:148,1));

Max_Min(2,1)=max(filtre(148:350,1));
Max_Min(2,2)=min(filtre(148:350,1));

Max_Min(3,1)=max(filtre(350:550,1));
Max_Min(3,2)=min(filtre(350:550,1));

Max_Min(4,1)=max(filtre(550:750,1));
Max_Min(4,2)=min(filtre(550:750,1));

Max_Min(5,1)=max(filtre(750:989,1));
Max_Min(5,2)=min(filtre(750:989,1));

%%%%% automatisé
ranges=[1, 148; 148, 350; 350, 550; 550, 750; 750, 989];
Max_Min1=zeros(size(ranges, 1), 2);

for i = 1:size(ranges, 1);
    Max_Min1(i, 1)=max(filtre(ranges(i, 1):ranges(i, 2), 1));
    Max_Min1(i, 2)=min(filtre(ranges(i, 1):ranges(i, 2), 1));
end;
Min=Max_Min1(:,2);
Max=Max_Min1(:,1);


%%%%%%%%%%%%%%%%%%%%%%
%% Solution prof
for i=1:length(loc);
    if i==1
        SS=TD5(1:loc(i));
        hold on;
        plot(Temps(1:loc(1)),SS,'k');
        [Val,Ind]=max(SS);
        IMax(i)=Ind;
        VMax(i)=Val;
        plot(Temps(Ind),SS(Ind),'y*','MarkerSize',30);
    else
        SS=TD5(loc(i-1):loc(i));
        [Val,Ind]=max(SS);
        IMax(i)=Ind+loc(i-1)-1;
        VMax(i)=Val;
        hold on;
        plot(Temps(Ind+loc(i-1)-1),TD5(Ind+loc(i-1)-1),'k');
        plot(Temps(Ind+loc(i-1)-1),TD5(Ind+loc(i-1)-1),'y*','MarkerSize',30);
    end;
end;