Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bode plots are translated!!!

265 views
Skip to first unread message

Lupino

unread,
Jan 18, 2005, 12:07:07 PM1/18/05
to
Hi everyone,
I've got a problem with scilab-3.0 (win and linux version).

It seems that bode plots are not right. In fact, I type these commands:

-->s = poly(0, 's')
s =

s

-->syst=syslin('c', 1/s)
syst =

1
-
s

-->bode(syst)

And then I check the crossover (or crossing?) frequency.
It is, if I'm right, the frequency at which the restriction to
s=j*w of the transfer function H(s) has a modulus of 0 dB (crosses the
frequency axis).
Graphically, it is near 2*10^(-1).

But if I seek for it in an analytical way I find this:

|H(jw)| = 1 <=> 1/|jw| = 1 <=> 1/w = 1 <=> w = 1 (!!!)
What am I doing wrong?

In addition to this, today at the university I drawed the bode plot of a
simple transfer function (it was, I think, 2/(s+2)^2). And scilab bode
plot is different from matlab bode plot, but matlab does report the
correct crossover frequency!!!

Please help me.. can I trust scilab bode plots?
TIA,

Andrea

Tim Wescott

unread,
Jan 18, 2005, 12:21:57 PM1/18/05
to
Lupino wrote:

The Scilab bode plot shows the frequency in Hz. When you use the form
H(jw) you are are expressing the frequency in radians per second. I
suspect that MatLab does it in radians per second -- is everything
correct but for a scaling of 1/2*pi? if so, then there you are.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Lupino

unread,
Jan 18, 2005, 5:34:17 PM1/18/05
to
Il Tue, 18 Jan 2005 09:21:57 -0800, Tim Wescott ha scritto:

>> Please help me.. can I trust scilab bode plots? TIA,
>>
>> Andrea
>
> The Scilab bode plot shows the frequency in Hz. When you use the form
> H(jw) you are are expressing the frequency in radians per second. I
> suspect that MatLab does it in radians per second -- is everything correct
> but for a scaling of 1/2*pi? if so, then there you are.

AH-HA!
Thanks!! I cannot verify if the scaling is correct.. I don't have matlab
at home.

How can I fix it? And.. another question: how can I easily identify the
crossover frequency and the phase margin in bode plots with scilab?
Using matlab, if I click on the graph, I can (almost easily) pick the
right frequency and I get the info I need..

Can you help me?
THANKS A LOT! I heavily suggested scilab over PIRATE matlab to my
colleagues, but this "error" got me TOTALLY STUCK!!

One of them said "you know, it's opensource software, so you can't trust
it!". I know it's the opposite thing: just because it's opensource
software, if I don't trust it I open the sources and I check it (If I'm
able to do it... :D ).
I had to shut up. I wasn't able to defend scilab!!!!

Thanks again,
Andrea.

Tim Wescott

unread,
Jan 18, 2005, 6:09:53 PM1/18/05
to
Lupino wrote:

For gain and phase margins I make a little macro that takes a frequency
response vector (which you have to generate) and searches for gain and
phase crossings, then gives you gain and phase margins. The nice thing
is that it's automatic. The not-so-nice thing is that if you're going
from real data things often get very questionable at the frequency
extremes and you may see lots of phantom phase crossings.

Lupino

unread,
Jan 18, 2005, 6:13:38 PM1/18/05
to
Il Tue, 18 Jan 2005 15:09:53 -0800, Tim Wescott ha scritto:

>> How can I fix it? And.. another question: how can I easily identify the
>> crossover frequency and the phase margin in bode plots with scilab?
>> Using matlab, if I click on the graph, I can (almost easily) pick the
>> right frequency and I get the info I need..
>

> For gain and phase margins I make a little macro that takes a frequency
> response vector (which you have to generate) and searches for gain and
> phase crossings, then gives you gain and phase margins. The nice thing is
> that it's automatic. The not-so-nice thing is that if you're going from
> real data things often get very questionable at the frequency extremes and
> you may see lots of phantom phase crossings.

Hmm.. I would be grateful to you if you'd post your macro (if you can): I
won't work with real data, I'll only need to check the results of my
exercises...

Thanks in advance. I'll seek in the manual for the method I have to use in
order to create the frequency response vector.

Tim Wescott

unread,
Jan 18, 2005, 6:33:37 PM1/18/05
to
Lupino wrote:

I don't have it here -- it's on a former employer's machine, along with
a copy of MatLab.

The basic idea goes like this:

* find the place where the gain (or phase) crosses the boundary. Say
it's split between x(56) and x(57).
* Use linear interpolation to find the "fractional index". Say
x(56) = 1.01 * e^j2.22 and x(57) = 0.97 * e^j2.14. Then the estimate
for the gain crossing is at 56.25.
* Use the "fractional index" to get phase and frequency. In this case
the phase would be 2.2 radians. Calculate the frequency in a similar
manner.

Of course, your points have to be close enough together that you can
assume fairly straight lines.

Nate

unread,
Jan 19, 2005, 11:11:26 AM1/19/05
to

Do this...

s=poly(0,'s');
s=s/(2*%pi);

...before you define your transfer function and you will get a bode
plot in rad/sec even though the x axis label will still say hz.

Lupino

unread,
Jan 20, 2005, 4:14:00 PM1/20/05
to
Il Wed, 19 Jan 2005 08:11:26 -0800, Nate ha scritto:

> Do this...
>
> s=poly(0,'s');
> s=s/(2*%pi);
>
> ...before you define your transfer function and you will get a bode plot
> in rad/sec even though the x axis label will still say hz.

Hey, it works!! Thanks..
Now I'm modifying bode.sci in order to achieve this without my
intervention. Is there a way to let all the 's' (or whatever var it uses)
be 's/(2*%pi)' ?

I looked a bit into syslin.. It seems that the output is a transfer
function that I can use with other functions.. I can sum the output etc..
but I don't know how to do this substitution!!

Thanks in advance..

Tim Wescott

unread,
Jan 21, 2005, 1:15:11 AM1/21/05
to
Lupino wrote:

Somewhere in bode.sci there has to be a multiplication by 2 pi, so you
should just be able to find that spot and take it out.

0 new messages