<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Look at bug reports 6744 and 6745 at <a class="moz-txt-link-freetext" href="http://bugzilla.scilab.org">http://bugzilla.scilab.org</a><br>
<br>
6744 has an  attachment with my own functions. Probably not perfect as
well !<br>
<br>
<br>
Vladímir Rodríguez a écrit :
<blockquote cite="mid:1268152835.3338.1.camel@accionamiento" type="cite">
  <pre wrap="">El mar, 09-03-2010 a las 16:39 +0100, David PICARD escribió:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Well, I eventually came up to the conclusion that both p_margin() and 
g_margin() are buggy. I had to write my own code to replace them.

I can give details upon request.

Regards.


David PICARD a écrit :
    </pre>
    <blockquote type="cite">
      <pre wrap="">I corrected the subject.

David PICARD a écrit :
      </pre>
      <blockquote type="cite">
        <pre wrap="">I get weird results when I try to calculate gain margin for transfer 
functions. For example, this one :

-->Hbo=syslin(1.0,(0.263-0.656*z+0.206*z^2+0.3*z^3)/(-0.263+0.656*z+0.28*z^2-1.674*z^3+z^4)) 

Hbo_s  =

                            2      3         0.263 - 0.656z + 0.206z 
+ 0.3z        ----------------------------------   
                         2        3   4  - 0.263 + 0.656z + 0.28z - 
1.674z + z It is a digital controller open loop transfer function.

Phase margin : p_margin(Hbo_s) returns 65.62, which is correct 
(checked with both a book and Matlab).
Gain margin : g_margin(Hbo_s) returns -41.06, which I is not what I 
expect.

So, I plot the frequency response with :
-->show_margins(Hbo_s,'nyquist')
to try to figure out the gain margin graphically.

The gain margin is the inverse of the gain of the transfer function 
when the phase is -180°).

The curve crosses the X axis at -0.368, which leads to gain_margin = 
1/0.368 = 2.7, which is the value given in my book and returned by 
Matlab (margin() ).
In addition, the blue line that I assume, shows the gain margin, 
extends way beyond -0.368, probably as far as -41.06.

Did I get something wrong here ? Thanks.

My configuration : Scilab 5.2.1, Windows XP SP3





        </pre>
      </blockquote>
      <pre wrap="">

      </pre>
    </blockquote>
  </blockquote>
  <pre wrap=""><!---->I am interested in every detail about it, I am going to use these
function in clases.
Thanks
  </pre>
</blockquote>
</body>
</html>