////////////////////////////////////// //Function plot_spectre // //Fonction qui affiche 10*log10(DSP) dans une fenetre // //nwin : numéro de fenêtre //DSP : vecteur de la DSP //step : pas fréqentiel //f1 : fréquence gauche //flength : largeur fréquentielle de la fenêtre //flag1 : flag normalisation //flag2 : flag échelle logarithmique //f3 : option supplémentaire // |--------|--------| // f1 f0 f2 // n1 n0 n2 function []=plot_spectre(nwin,DSP,step,f1,flength,flag1,flag2,f3) //Longueur max de la fenetre scilab win_len_max=2^19+2^18; //Longueur du vecteur DSP size_dsp=size(DSP,'*'); //Calcul bornes f2=f1+flength; n1=f1/step; n2=f2/step; //n=size_dsp/2+1+(n1:1:n2); n=(n1:1:n2); //Teste la longueur de la fenetre if(size(n,'*')>win_len_max) then error('Fenêtre trop large pour être affichée'); end; //Assigne et crée la fenêtre nwin xset("window",nwin); xbasc(nwin); xset("wdim",300,200); //normalise au maximum de la DSP if (flag1=="n") then DSP=DSP/max(DSP); end; //Affiche la DSP if(flag2=="ln") then //Calcul la puissance de 10 //supérieure à step if(~exists("f3")) then i=0;j=1; while (i==0) then if(int(step/10^j)<>0) then j=j+1; else i=1; end; end; b1=10^j; else b1=step; end; f=(f1:step:f2)-f1+1; plot2d("ln",f,10*log10(DSP(n))-10*log10(step),... ,"011",rect=[b1,min(10*log10(DSP(n+2))-10*log10(step)),... max(f),max(10*log10(DSP(n+2))-10*log10(step))]); else f=f1:step:f2; plot2d(f,10*log10(DSP(n)),... ,"011",rect=[min(f),min(10*log10(DSP(n))),max(f),max(10*log10(DSP(n)))]); end; endfunction