IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MATLAB Discussion :

problème utilisation de try catch


Sujet :

MATLAB

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    14
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : Belgique

    Informations forums :
    Inscription : Mars 2008
    Messages : 14
    Points : 15
    Points
    15
    Par défaut problème utilisation de try catch
    Bonjour,
    Je pensais avoir correctement utilisé le try catch, mais visiblement, ce n'est pas le cas... Quelqu'un pourrait-il 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
    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
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    %calculate h2O transmission
        function [tr1,tr2,tr3,tr4,tr5,tryy,tr6,trc]= h20trans(pa,p,kap,at1)
            %     tr1 is trans for 660 - 800 cm-1 h2O
            %     tr2 is co2 h2o overlap
            %     tr4 is ch4 h20 overlap
            %     tr5 is 1200-1350 n20 h20 overlap
            %      tr6 is 520-660 n2o h2o overlap
            %     trc is the emissivity of the 800-1200 cm-1 h2O cont.
            %     tryy is the emissivity of h20 cont 400-660 x tr rot
            tr1=zeros(20,20);
            tr2=zeros(20,20);
            tr3=zeros(20,20);
            tr4=zeros(20,20);
            tr5=zeros(20,20);
            tr6=zeros(20,20);
            tryy=zeros(20,20);
            trc=zeros(20,20);
            rc=zeros(20);
            ry=zeros(20);
            r2=zeros(20);
            r3=zeros(20);
     
            sig=5.67e-8;
            for i=1:18
                e=esat(at1(i));
                r=rwat(pa(i),e);
                e=e*.77*pa(i);
                u5=r*1033*(p(i+1)-p(i));
                rc(i)=trcont (800.,1200.,u5,at1(i),e);
                ry(i)=trcont(480.,800.,u5,at1(i),e);
                r2(i)=trcont(580.,740.,u5,at1(i),e);
                r3(i)=trc3(u5,at1(i),e);
            end
            for i=2:19
                for j=1:i-1
                    e=esat(at1(j));
                    r=rwat(pa(j),e);
                    if (j==1)
                        u4=r*1033*(p(j+1));
                    else
                        u4=r*1033*(p(j+1)-pa(j));
                    end
                    e=e*.77*pa(j);
                    tr= trcont(800.,1200.,u4,at1(j),e);
                    trc(j,i)=tr;
                    tr= trcont(480.,800.,u4,at1(j),e);
                    tryy(j,i)=tr;
                    tr=trcont(580.,740.,u4,at1(j),e);
                    tr2(j,i)=tr;
                    tr=trc3(u4,at1(j),e);
                    tr3(j,i)=tr;
                    tave=at1(j)*(p(j+1)-pa(j))*r*1033;
                    pave=pa(j)*(p(j+1)-pa(j))*r*1033;
                    for k=j+1:i-1
                        e=esat(at1(k));
                        r=rwat(pa(k),e);
                        u4=u4+r*1033*(p(k+1)-p(k));
                        trc(j,i)=trc(j,i)*rc(k);
                        tryy(j,i)=tryy(j,i)*ry(k);
                        tr2(j,i)=tr2(j,i)*r2(k);
                        tr3(j,i)=tr3(j,i)*r3(k);
                        tave=tave+at1(k)*r*1033*(p(k+1)-p(k));
                        pave=pave+pa(k)*r*1033*(p(k+1)-p(k));
                    end
                    pave=pave/u4;
                    tave=tave/u4;
                    e=esat(tave)*.77*(pave-.02)/.98;
                    if(e<(4.8e-6*pave))
                        e=(4.8e-6*pave);
                    end
                    [tr,trx,tch]= overlap(tave,pave,u4);
                    bl=3.742e-16*(73000^3)/((exp(1.438*730/tave))-1);
                    tr1(j,i)=14000.*bl*(1-tr)/(sig*tave^4);
                    tr2(j,i)=tr2(j,i)*tch;
                    bl=3.742e-16*(64000^3)/((exp(1.438*640/tave))-1);
                    tryy(j,i)=32000.*bl*trx*(1-tryy(j,i))/(sig*tave^4);
                    th4= ch4ovl(pave,u4,tave,e);
                    tr4(j,i)=th4;
                    tr=trrn(pave,u4);
                    tr5(j,i)=tr;
                    tr=trr6(tave,pave,u4);
                    tr6(j,i)=tr;
                    bl=3.742e-16*(100000^3)/((exp(1.438*1000/tave))-1);
                    trc(j,i)=40000*bl*(1-trc(j,i))/(sig*tave^4);
                end
            end
            for i=1:19
                for j=1:i
                    try
                    if j==19 
                        error('Opps0');
                    else
                    e=esat(at1(i));
                    r=rwat(pa(i),e);
                    u4=r*1033*(pa(i)-p(i));
                    tave=at1(i)*(pa(i)-p(i))*r*1033;
                    pave=pa(i)*(pa(i)-p(i))*r*1033;
                    e=e*0.77*pa(i);
                    tr=trcont(800,1200,u4,at1(i),e);
                    trc(i,j)=tr;
                    tr=trcont(480,800,u4,at1(i),e);
                    tryy(i,j)=tr;
                    tr=trcont(580,740,u4,at1(i),e);
                    tr2(i,j)=tr;
                    tr=trc3(u4,at1(i),e);
                    tr3(i,j)=tr;
                    for k=j:i-1
                        e=esat(at1(k));
                        r=rwat(pa(k),e);
                        u4=u4+r*1033*(p(k+1)-p(k));
                        tave=tave+at1(k)*r*1033*(p(k+1)-p(k));
                        pave=pave+pa(k)*r*1033*(p(k+1)-p(k));
                        trc(i,j)=trc(i,j)*rc(k);
                        tryy(i,j)=tryy(i,j)*ry(k);
                        tr2(i,j)=tr2(i,j)*r2(k);
                        tr3(i,j)=tr3(i,j)*r3(k);
                    end
                    pave=pave/u4;
                    tave=tave/u4;
                    e=esat(tave)*0.77*(pave-0.02)/0.98;
                    if(e<(4.8e-6*pave))
                        e=(4.8e-6*pave);
                    end
                    [tr,trx,tch]=overlap(tave,pave,u4);
                    bl=3.742e-16*(73000^3)/((exp(1.438*730/tave))-1);
                    tr1(i,j)=14000*bl*(1-tr)/(sig*tave^4);
                    tr2(i,j)=tch*tr2(i,j);
                    bl=3.742e-16*(64000^3)/((exp(1.438*640/tave))-1);
                    tryy(i,j)=32000*bl*trx*(1-tryy(i,j))/(sig*tave^4);
                    th4=ch4ovl(pave,u4,tave,e);
                    tr4(i,j)=th4;
                    tr=trrn(pave,u4);
                    tr5(i,j)=tr;
                    tr=trr6(tave,pave,u4);
                    tr6(i,j)=tr;
                    bl=3.742e-16*(100000^3)/((exp(1.438*1000/tave))-1);
                    trc(i,j)=40000*bl*(1-trc(i,j))/(sig*tave^4);
                    end
                    catch
                        if strcmp(lasterror,'Opps0')
                        continue
                        end
                    end
            end
            tr1(19,19)=0;
            tr2(19,19)=1;
            tr3(19,19)=1;
            tr4(19,19)=1;
            tr5(19,19)=1;
            tr6(19,19)=1;
            trc(19,19)=0;
            tryy(19,19)=0;
            end
        end

  2. #2
    Expert éminent sénior
    Avatar de Caro-Line
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    9 458
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2007
    Messages : 9 458
    Points : 14 828
    Points
    14 828
    Par défaut
    Bonjour,

    Ton code me parait bien compliqué...
    Après pour le try, catch, qu'est-ce qui ne fonctionne pas ?

    Sur ma version de MATLAB la fonction lasterror renvoie une structure donc le test du strcmp ne marchera jamais...Mais de toute façon le programme continuera à tourner quelque soit l'erreur rencontrée dans le try.

    Il faudrait essayer de faire un petit programme exemple de ton problème pour que l'on puisse aussi le tester.

Discussions similaires

  1. [Débutant] Utiliser un Try Catch
    Par Foudogue dans le forum Windows Forms
    Réponses: 1
    Dernier message: 26/08/2014, 08h44
  2. [2012] Problème avec l'utilisation de TRY/CATCH à l'intérieure d'un trigger
    Par Fog-Thunder dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 12/02/2014, 09h20
  3. [Débutant] Problème Thread et Try-Catch
    Par AsyLuM dans le forum VB.NET
    Réponses: 3
    Dernier message: 16/10/2013, 20h26
  4. Utilisation de try catch dans une procédure de backup de database
    Par megtrinity dans le forum MS SQL Server
    Réponses: 6
    Dernier message: 05/11/2009, 14h53
  5. [C#] Comment bien utiliser des TRY CATCH
    Par UNi[FR] dans le forum C#
    Réponses: 5
    Dernier message: 14/11/2007, 19h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo