tags:

views:

72

answers:

2
+1  A: 

Behavor #1 makes sense, since the input is assumed to be radians, not degrees. The adjustment adds pi/2 if you're above jump tolerance, so that's fine.

What would be nice was if unwrap had a feature that allowed it to work on any kind of series, not simply on radian angles.

The jump tolerance is not sufficient to tell whether you have a series in radian, or degree, or any other kind, so there would need to be an additional input.

Jonas
interesting... my point with interpretation #2 is that (as you mention) there really isn't any particular tie to angles in radians, degrees, or whatever except for the wraparound period, which by default is 2pi, but can be anything (for degrees it's 360, for 16-bit integers it's 65536, etc). Jump tolerance is supposed to be 1/2 the wraparound period... I'm not sure why you'd ever pick a different relation between the two.
Jason S
I guess you could have two ways for how the function works. Either it's specific to radians (as it says in the documentation), and you can choose your jump tolerance freely. Or you fix jump tolerance at 1/2 wraparound, and you're using that input for any kind of range.
Jonas
I'd vote for the latter, but that's just my take on it. I may end up just writing my own function (it's fairly trivial) and not depending on Mathworks anymore for a correctly-functioning unwrap() implementation.
Jason S
+1  A: 

I had always assumed that the second behavior was the actual one, but never tested it out. A literal reading of the help file does indicate behavior #1. But that's not what one would ever want to do. As a simple example, consider doing an unwrapping in degrees

x = mod(0:30:720, 360)
y = unwrap(x,180)

obviously you would want y = 0:30:720, but instead you get ...

y =

Columns 1 through 7

     0   30.0000   60.0000   90.0000  120.0000  150.0000  180.0000

Columns 8 through 14

210.0000  240.0000  270.0000  300.0000  330.0000  333.0088  363.0088

Columns 15 through 21

393.0088  423.0088  453.0088  483.0088  513.0088  543.0088  573.0088

Columns 22 through 25

603.0088  633.0088  663.0088  666.0176

which is wrong (y no longer corresponds to the same angle as x, which is the point of unwrap)

Can anyone give an example of when you would want behavior #1 (the current behavior?)

Marc

related questions