Partage
  • Partager sur Facebook
  • Partager sur Twitter

Matlab Erreur code

Sujet résolu
    7 février 2019 à 18:51:23

    Bonjour , voici mon code qui effectue la transformation Foster/cauer j'ai un erreur a la ligne 41 . Mais je ne comprend pourquoi l’opération engendre une erreur?

    Merci,

    clear all;
    R_Foster(1) = 0.196800;
    R_Foster(2) = 0.073300;
    R_Foster(3) = 0.050900;
    R_Foster(4) = 0.020900;
    %
    C_Foster(1) = 0.586911;
    C_Foster(2) = 0.127422;
    C_Foster(3) = 0.016169;
    C_Foster(4) = 0.005694;
    
    try 
        s = tf('s');
        sys_Foster = tf(R_Foster(1)/(1+R_Foster(1)*C_Foster(1)*s)+R_Foster(2)/(1+R_Foster(2)*C_Foster(2)*s)+...
            R_Foster(3)/(1+R_Foster(3)*C_Foster(3)*s)+R_Foster(4)/(1+R_Foster(4)*C_Foster(4)*s));
        [N_tf,D_tf] = tfdata(sys_Foster);
        chain_length = numel(D_tf{1})-1; % this script works for any length Cauer-type RC ladder network (chain)
        D = N_tf{1}; D(1) = []; N = D_tf{1}; % admittance --> the reciprocal of transfer function is used
    catch exception1
        try 
            syms s
            [N_tf,D_tf] = numden(R_Foster(1)/(1+R_Foster(1)*C_Foster(1)*s)+R_Foster(2)/(1+R_Foster(2)*C_Foster(2)*s)+...
                R_Foster(3)/(1+R_Foster(3)*C_Foster(3)*s)+R_Foster(4)/(1+R_Foster(4)*C_Foster(4)*s));
            D = sym2poly(N_tf);
            N = sym2poly(D_tf);
            chain_length = numel(N)-1;
        catch exception2
            disp('Please explicitely define the numerator and denominator coefficients.');
            return % If you reached this line, please replace it with your N and D.
        end
    end
    
    for i = 1:chain_length, % Continued fraction
        n = max([N D]);
        N = N/n; D = D/n;
        C_Cauer(i)=N(1)/D(1); % consecutive capacitances in the chain
        Dnew = D*D(1);
        Nnew = N*D(1);
        b = [D 0];
        disp([b]);
        a = Nnew-[D 0] * N(1); 
        Nnew(1) = [];
        R_Cauer(i) = Dnew(1)/Nnew(1); % consecutive resistances in the chain
        D = Dnew*Nnew(1)-Nnew*Dnew(1); 
        D(1) = [];
        N = Nnew*Nnew(1);
    end

    -
    Edité par maximeaube00 7 février 2019 à 18:56:45

    • Partager sur Facebook
    • Partager sur Twitter

    Matlab Erreur code

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown