Re: Fitting step function
- To: mathgroup at smc.vnet.net
- Subject: [mg122100] Re: Fitting step function
- From: Jacopo Bertolotti <jacopo.bertolotti at gmail.com>
- Date: Fri, 14 Oct 2011 05:52:42 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201110120744.DAA16264@smc.vnet.net>
Maybe I totally misunderstood your point but, if you really want to know
where the phase jumps (likely phase wraps) happen, wouldn't be a lot
easier to just look when the difference between two adjacent points is
bigger than Pi or something like that?
Here is an example code (sorry, it is not easily readable but I hope it
makes my point clear):
phasedata = Table[Arg[Exp[I x^2]], {x, 0, 10, 0.01}]; (*any phase data.
Here I am just faking some.*)
jumps = Drop[ Flatten@Position[Round[Differences[phasedata]/(2 Pi)],
Except[0]], 1]; (*find those points whose difference with the previous
one is approximately a multiple of 2 Pi. There is a spurious 0 that is
eliminated with the Drop command. *)
jumps = Table[{jumps[[i]], 0}, {i, 1, Dimensions[jumps][[1]]}]; (* give
the coordinates a y value just for the sake of plotting *)
ListPlot[phasedata, Joined -> True, Epilog -> {PointSize[Medium], Red,
Map[Point, jumps]}] (*It works!!!*)
Regards
Jacopo
On 10/12/2011 09:44 AM, premiumxy wrote:
> Hello,
>
> I have the following problem: I have a set of data about some phase information of a signal. At certain points there is a clear step of 180 degrees.
>
> I would like to fit this data to find the x-coordinates of these steps. I have the feeling that "normal" step-functions in Mathematica (such as UnitStep, HeavisideTheta, Sign...) are not varied in the fit-routines (such as NonlinearModelFit). I guess it this is caused by the functions not being continuous.
>
> I would appreciate any hints for this quite simple (?)problem. The only option that I can currently see is to create a "step-like" continuous function such as Tanh[A x] (with A>>1)
>
> Thanks!
>
>
- References:
- Fitting step function
- From: premiumxy <spam@stefanabel.com>
- Fitting step function