<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Le 19/09/2011 17:06, Reinaldo a écrit :
    <blockquote
      cite="mid:1316444819.22866.YahooMailNeo@web45509.mail.sp1.yahoo.com"
      type="cite">
      <pre style="font-family: Monospaced; font-style: normal;"><span style="color: rgb(1, 168, 1); font-style: italic;">/ Define "s" as variable </span>
<span style="color: rgb(1, 168, 1); font-style: italic;">// (s é um polinômio de raiz zero)</span>
<span style="color: rgb(0, 0, 0);">s</span> <span style="color: rgb(92, 92, 92);">=</span> <span style="color: rgb(50, 185, 185);">poly</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">0</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">'</span><span style="color: rgb(188, 143, 143);">s</span><span style="color: rgb(188, 143, 143);">'</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">;</span>
<span style="color: rgb(1, 168, 1); font-style: italic;">// Define the transfer function:</span></pre>
      <pre style="font-family: Monospaced; font-style: normal;"><span style="color: rgb(1, 168, 1); font-style: italic;"></span><span style="color: rgb(0, 0, 0);">H</span> <span style="color: rgb(92, 92, 92);">=</span> <span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(0, 0, 0);">s</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(92, 92, 92);">/</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(0, 0, 0);">s</span><span style="color: rgb(92, 92, 92);">+</span><span style="color: rgb(188, 143, 143);">1</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">;</span>
<span style="color: rgb(1, 168, 1); font-style: italic;">// Define the frequency range (Hz)</span>
<span style="color: rgb(0, 0, 0);">f</span> <span style="color: rgb(92, 92, 92);">=</span> <span style="color: rgb(188, 143, 143);">0.001</span><span style="color: rgb(255, 170, 0);">:</span><span style="color: rgb(188, 143, 143);">0.001</span><span style="color: rgb(255, 170, 0);">:</span><span style="color: rgb(188, 143, 143);">100</span><span style="color: rgb(0, 0, 0);">;</span>
<span style="color: rgb(1, 168, 1); font-style: italic;">// Calculate the frequency-response:</span></pre>
      <pre style="font-family: Monospaced; font-style: normal;"><span style="color: rgb(1, 168, 1); font-style: italic;"></span><span style="color: rgb(0, 0, 0);">y</span> <span style="color: rgb(92, 92, 92);">=</span> <span style="color: rgb(50, 185, 185);">freq</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(0, 0, 0);">H</span><span style="color: rgb(92, 92, 92);">.</span><span style="color: rgb(170, 170, 170);">num</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">H</span><span style="color: rgb(92, 92, 92);">.</span><span style="color: rgb(170, 170, 170);">den</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">2</span><span style="color: rgb(92, 92, 92);">*</span><span style="color: rgb(218, 112, 214);">%pi</span><span style="color: rgb(92, 92,
 92);">*</span><span style="color: rgb(218, 112, 214);">%i</span><span style="color: rgb(92, 92, 92);">*</span><span style="color: rgb(0, 0, 0);">f</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">;</span>
<span style="color: rgb(1, 168, 1); font-style: italic;">// Calculate the absolute value function module:</span></pre>
      <pre style="font-family: Monospaced; font-style: normal;"><span style="color: rgb(1, 168, 1); font-style: italic;"></span><span style="color: rgb(0, 0, 0);">yabs</span> <span style="color: rgb(92, 92, 92);">=</span> <span style="color: rgb(50, 185, 185);">abs</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(0, 0, 0);">y</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">;</span> 
<span style="color: rgb(1, 168, 1); font-style: italic;">// Calcula the function module in dB</span>
<span style="color: rgb(0, 0, 0);">ym</span> <span style="color: rgb(92, 92, 92);">=</span> <span style="color: rgb(188, 143, 143);">20</span><span style="color: rgb(92, 92, 92);">*</span><span style="color: rgb(174, 92, 176); text-decoration: underline;">log10</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(50, 185, 185);">abs</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(0, 0, 0);">y</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">;</span>
</pre>
      <pre style="font-family: Monospaced; font-style: normal;"><span style="color: rgb(1, 168, 1); font-style: italic;">// Calculate the phase function in degree:</span>
<span style="color: rgb(0, 0, 0);">yf</span> <span style="color: rgb(92, 92, 92);">=</span> <span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">180</span><span style="color: rgb(92, 92, 92);">/</span><span style="color: rgb(218, 112, 214);">%pi</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(92, 92, 92);">*</span><span style="color: rgb(50, 185, 185);">atan</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(50, 185, 185);">imag</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(0, 0, 0);">y</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(50, 185, 185);">real</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(0, 0, 0);">y</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(74, 85, 219);">)</span><span style="color:
 rgb(0, 0, 0);">;</span>

<span style="color: rgb(1, 168, 1); font-style: italic;">// open and clean the graph window</span>
<span style="color: rgb(0, 0, 0);">xbasc</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">,</span>
<span style="color: rgb(1, 168, 1); font-style: italic;">// Divide the graph window in three rows:</span>
<span style="color: rgb(174, 92, 176); text-decoration: underline;">subplot</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">3</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">1</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">1</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">,</span>
<span style="color: rgb(50, 185, 185);">plot2d</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">'</span><span style="color: rgb(188, 143, 143);">ln</span><span style="color: rgb(188, 143, 143);">'</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">f</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">yabs</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">style</span><span style="color: rgb(92, 92, 92);">=</span><span style="color: rgb(188, 143, 143);">2</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">,</span>
<span style="color: rgb(50, 185, 185);">xgrid</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">,</span>
<span style="color: rgb(50, 185, 185);">xtitle</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(188, 143, 143);">Modulo em valores absolutos da Função de Transferência</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(188, 143, 143);">Freqüência [Hz]</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(188, 143, 143);">Módulo em dB</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">;</span></pre>
      <pre style="font-family: Monospaced; font-style: normal;"><span style="color: rgb(174, 92, 176); text-decoration: underline;">subplot</span><span style="color:
 rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">3</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">1</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">2</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">,</span>
<span style="color: rgb(50, 185, 185);">plot2d</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">'</span><span style="color: rgb(188, 143, 143);">ln</span><span style="color: rgb(188, 143, 143);">'</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">f</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">ym</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">style</span><span style="color: rgb(92, 92, 92);">=</span><span style="color: rgb(188, 143, 143);">2</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">,</span>
<span style="color: rgb(50, 185, 185);">xgrid</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">,</span>
<span style="color: rgb(50, 185, 185);">xtitle</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(188, 143, 143);">Modulo em dB da Função de Transferência</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(188, 143, 143);">Freqüência [Hz]</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(188, 143, 143);">Módulo em dB</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">;</span>
</pre>
      <pre style="font-family: Monospaced; font-style: normal;"><span style="color: rgb(174, 92, 176); text-decoration: underline;">subplot</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">3</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">1</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">3</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">,</span>
<span style="color: rgb(50, 185, 185);">plot2d</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">'</span><span style="color: rgb(188, 143, 143);">ln</span><span style="color: rgb(188, 143, 143);">'</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">f</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">yf</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">style</span><span style="color: rgb(92, 92, 92);">=</span><span style="color: rgb(188, 143, 143);">3</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">,</span>
<span style="color: rgb(50, 185, 185);">xtitle</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(188, 143, 143);">Fase da Função de Transferência</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(188, 143, 143);">Freqüência [Hz]</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(188, 143, 143);">Fase em Graus</span><span style="color: rgb(188, 143, 143);">"</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">;</span>
<span style="color: rgb(50, 185, 185);">xgrid</span><span style="color: rgb(74, 85, 219);">(</span><span style="color: rgb(74, 85, 219);">)</span><span style="color: rgb(0, 0, 0);">;</span></pre>
    </blockquote>
    <br>
    You can modify the margins properties for that <br>
    Note that you can use repfreq to compute the frequency dicretisation
    and the frequency response<br>
    the following code pllies both solutions <br>
    <br>
    <br>
    <br>
    // Define "s" as variable <br>
    // (s é um polinômio de raiz zero)<br>
    s = poly(0,'s');<br>
    // Define the transfer function:<br>
    H = syslin('c',(s)/(s+1)); // set continuous time<br>
    [f,y]=repfreq(H,0.001,100);<br>
    <br>
    // Calculate the absolute value function module:<br>
    <br>
    yabs = abs(y); <br>
    // Calcula the function module in dB<br>
    ym = 20*log10(abs(y));<br>
    <br>
    // Calculate the phase function in degree:<br>
    yf = (180/%pi)*atan(imag(y), real(y));<br>
    <br>
    // open and clean the graph window<br>
    clf(),<br>
    // Divide the graph window in three rows:<br>
    subplot(3,1,1),<br>
    plot2d('ln',f,yabs,style=2),<br>
    ax=gca();<br>
    ax.margins(3:4)=0.24;<br>
    xgrid(),<br>
    xtitle("Modulo em valores absolutos da Função de
    Transferência","Freqüência [Hz]","Módulo em dB");<br>
    <br>
    subplot(3,1,2),<br>
    plot2d('ln',f,ym,style=2),<br>
    ax=gca();<br>
    ax.margins(3:4)=0.24;<br>
    xgrid(),<br>
    xtitle("Modulo em dB da Função de Transferência","Freqüência
    [Hz]","Módulo em dB");<br>
    <br>
    subplot(3,1,3),<br>
    plot2d('ln',f,yf,style=3),<br>
    xtitle("Fase da Função de Transferência","Freqüência [Hz]","Fase em
    Graus");<br>
    ax=gca();<br>
    ax.margins(3:4)=0.24;<br>
    xgrid();<br>
    <br>
    <br>
    <br>
    Serge Steer<br>
    INRIA<br>
  </body>
</html>