Bonjour, je dois rendre un code plus mercredi.

Je dois utiliser la méthode de la bissection, seulement ma boucle est infinie et je ne vois pas mon erreur. Quelqu'un pourrait-il m'éclairer?
Voici mon code, j'espère que vous saurez m'aider! :(


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
function Q32_2(Xmax_mid, G, Y0, Tps_ch_target)
 
fichier= xlsread ('PerteEtGain.xlsx');
 
x= fichier(1,:);
y= fichier (2,:);
 
[G]= G (x,y);
 
function[G]= G (x,y)
G=spline(x, y);
end
 
 
Y0= [15 15 15 15 15];
%Y1=Y0;
Tempschauffe= 0;
option= odeset ('RELTOL ', 10E-8);
Tps_ch_inf = 0;
Tps_ch_sup = 20;
 
    Xmax_target =input('Veuillez encoder une tempÈrature maximale de confort: '); 
 
    [T,X] = ode45(@(t,Y0)odefunction4(t,Y0,G,3,Tempschauffe), [0 24], Y0,option);
            X1 = X(end, 1);
            Y1= X(end,:);
 
    [T,X] = ode45(@(t,Y1)odefunction4(t,Y1,G,3,Tempschauffe), [0 24], Y1,option);
    moy= (X(:,1)+X(:,5))/2;
    Xmax_mid= moy;
 
    tol =0.001;
 
 
    tic
    while abs(Xmax_target - Xmax_mid) >= tol 
 
         Tps_ch = (Tps_ch_sup+Tps_ch_inf)/2;
         Xmax_mid= Xmax(Tps_ch,Y1,G);
 
        if Xmax_mid == Xmax_target
            Tps_ch_target = Tps_ch;
 
        else
            if Xmax_mid>Xmax_target
                Tps_ch_sup = Tps_ch;
 
            elseif Xmax_mid < Xmax_target
                Tps_ch_inf = Tps_ch;
            end
            Tps_ch_target =Tps_ch_inf;
        end
        Tps_ch_target= Tps_ch_sup;
         %Xmax_mid= Xmax(Tps_ch_target,Y1,G);
    end
    Tps_ch_target
    toc

et odefunction4 est:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
function [dY] = odefunction4 (t,Y0,G,choix,Tempschauffe)
 
    G=ppval(G,t);
 
    %données
    Ccc = 50; 
    Cc1 = 50;
    Cc2 = 10;
    Croom = 12;
    Cw = 30; 
    Rcc_c1 = 0.05;
    Rx = 0.025;
    Rc2_cc = 0.02;
    Rr_s = 0.1;
    Rs_c2 = 0.183;
    Rw = 0.15;
 
 
    Troom = Y0(1);
    Tt = Y0(2);
    Tcc = Y0(3);
    Tc1 = Y0(4);
    Tc2 = Y0(5);
 
    Tw = Scenario(choix,t, Tt,Tempschauffe);
 
    dY = zeros(5,1);
 
 
    % Dérivée de Tcc (Eq1)
    dY(3,1)=((-1/Rcc_c1)*(Tcc-Tc1)-(1/Rx)*(Tcc-Tt)+(1/Rc2_cc)*(Tc2-Tcc))/Ccc;
 
    % Dérivée de Tc1 (Eq2)
    dY(4,1)=(-(1/Rcc_c1)*(Tc1-Tcc))/Cc1;
 
    %Dérivée de Tc2 (Eq3)
    dY(5,1)=(-(1/Rc2_cc)*(Tc2-Tcc)+(1/(Rr_s+Rs_c2)*(Troom-Tc2)))/Cc2;
 
    %Dérivée de Troom (Eq4)
    dY(1,1)=(-(1/(Rr_s+Rs_c2))*(Troom-Tc2)+G)/Croom;
 
    %Dérivée de Tt (Eq5)
    dY(2,1)=((-1/Rx)*(Tt-Tcc)-(1/Rw)*(Tt-Tw))/Cw;
 
 
end