Re: Re: Making a phase plot
- To: mathgroup at smc.vnet.net
- Subject: [mg62562] Re: [mg62549] Re: Making a phase plot
- From: Pratik Desai <pdesai1 at umbc.edu>
- Date: Mon, 28 Nov 2005 00:57:45 -0500 (EST)
- References: <dm95mr$70i$1@smc.vnet.net> <200511270741.CAA26160@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
John Doty wrote:
>Milind Gupta wrote:
>
>
>
>>Hello,
>> I wanted to plot the phase of a transfer function. I was doing it like
>>this:
>>
>>LogLinearPlot[Phase[w], {w, 0, wmax}]
>>
>> Where Phase is calculated using the ArcTan function. The problem is tha=
>>t
>>the ArcTan function rounds up the result to positive values when the phase
>>goes below -pi. But I want the phase to keep going negative values upto
>>infinity. Is there a way to do this using some standard functions?
>>
>>
>
>Well, of course ArcTan can't tell which branch you want. If you can make
>a list of your phases, sampled often enough that the phase difference is
>always less than Pi, the following will unwind them, figuring out which
>branch to use:
>
>unwind[ p_ ] := Module [
> {
> off = 0,
> pi = Pi//N,
> r = p,
> t,
> i
> },
>
> For[ i = 2, i <= Length[ p ], i += 1,
> r[[i]] += off;
> If[ Abs[ r[[i]]-r[[i-1]]] > pi,
> t = 2 pi Sign[ r[[i]]-r[[i-1]]];
> off -= t;
> r[[i]] -= t
> ]
> ];
> r
>]
>
>Wrote this about 10 years ago for a demodulator design project. I think
>it's about the longest and most procedural Mathematica function I ever
>wrote. Not my usual style at all, but it worked...
>
>-jpd
>
>
>
Why not use Arg, I think it takes care of everything. Everytime I use
the ArcTan function I have to remember the quadrant stuff and everytime
I keep forgetting it :-) . I tested Arg for this and it used to give me
the correct answer atleast in Ver 5
--
Pratik Desai
Graduate Student
UMBC
Department of Mechanical Engineering
Phone: 410 455 8134
- References:
- Re: Making a phase plot
- From: John Doty <jpd@whispertel.LoseTheH.net>
- Re: Making a phase plot