Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Making a phase plot

  • To: mathgroup at
  • Subject: [mg62562] Re: [mg62549] Re: Making a phase plot
  • From: Pratik Desai <pdesai1 at>
  • Date: Mon, 28 Nov 2005 00:57:45 -0500 (EST)
  • References: <dm95mr$70i$> <>
  • Sender: owner-wri-mathgroup at

John Doty wrote:

>Milind Gupta wrote:
>>     I wanted to plot the phase of a transfer function. I was doing it like
>>LogLinearPlot[Phase[w], {w, 0, wmax}]
>>    Where Phase is calculated using the ArcTan function. The problem is tha=
>>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...
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
Department of Mechanical Engineering
Phone: 410 455 8134

  • Prev by Date: Re: How to define and plot a periodic signal?
  • Next by Date: Re: Types in Mathematica
  • Previous by thread: Re: Making a phase plot
  • Next by thread: Re: Making a phase plot