Trouble Unwrapping Phase Data

9 visualizzazioni (ultimi 30 giorni)
Spencer Ferris
Spencer Ferris il 9 Dic 2023
Risposto: Akshat Dalal il 18 Dic 2023
I am having some trouble iterating through some circular voltage data that ranges from 4.5 to .5. As the data approaches the max and min, there will be a sudden transition from a low value near the minimum (i.e. .500001) to a high value near the max (i.e. 4.49999), and vice versa if going in the other direction. In other words, the data is circular and could be represented with degrees or radians. I have confirmed that the data never goes above or reaches 4.5 and never goes below or reaches .5.
I'm trying to manually unwrap the data (I've tried a few functions, such as unwrap(), with no success, but if you have suggestions I am open to trying them out) but am having issues where I am still seeing jumps in the unwrapped/accumulated values that I end up with after my iteration through the structure they are contained within. The code I wrote seems to mostly work but when there are transitions from the max (~4.5) to the min (~.5) there are still jumps in the value I get as output. Here's the code I've tried.
% Intialize the size of the array first.
BinaryDataStructure.Channel0BinaryDataUnwrappedVoltage = zeros(size(BinaryDataStructure.Channel0BinaryDataNewTimeBase));
Ch0NumberOfCycles = 0;
JumpsValue = 2.0;
% Manual unwrapping of VOLTAGE data.
for i = 1:length(BinaryDataStructure.Channel0BinaryDataNewTimeBase)
if i == 1
BinaryDataStructure.Channel0BinaryDataUnwrappedVoltage(i) = BinaryDataStructure.Channel0BinaryDataNewTimeBase(i);
BinaryDataStructure.Channel1BinaryDataUnwrappedVoltage(i) = BinaryDataStructure.Channel1BinaryDataNewTimeBase(i);
end
if i > 1
% Channel 0 - Voltage INCREASES when going in the right direction.
% If it is a non-jump voltage transition.
if abs(BinaryDataStructure.Channel0BinaryDataNewTimeBase(i) - BinaryDataStructure.Channel0BinaryDataNewTimeBase(i-1)) < JumpsValue
BinaryDataStructure.Channel0BinaryDataUnwrappedVoltage(i) = abs(BinaryDataStructure.Channel0BinaryDataNewTimeBase(i) + (4*(Ch0NumberOfCycles)));
else
if BinaryDataStructure.Channel0BinaryDataNewTimeBase(i) - BinaryDataStructure.Channel0BinaryDataNewTimeBase(i-1) < 0
Ch0NumberOfCycles = Ch0NumberOfCycles + 1;
BinaryDataStructure.Channel0BinaryDataUnwrappedVoltage(i) = BinaryDataStructure.Channel0BinaryDataNewTimeBase(i) + (4*Ch0NumberOfCycles); %ADJUST USING THIS ONE!!!
end
if BinaryDataStructure.Channel0BinaryDataNewTimeBase(i) - BinaryDataStructure.Channel0BinaryDataNewTimeBase(i-1) > 0
Ch0NumberOfCycles = Ch0NumberOfCycles - 1;
BinaryDataStructure.Channel0BinaryDataUnwrappedVoltage(i) = BinaryDataStructure.Channel0BinaryDataNewTimeBase(i) + (4*Ch0NumberOfCycles); %ADJUST USING THIS ONE!!!
end
end
end
end
Based on the direction the change in voltage goes in during the transition points (which are captured by the Jumps value, the data is sampled at 3840hz and there is no way there would be a jump that big other than during the transition points) the number of total cycles is either increased or decreased. And then I use this to update the value of the Unwrapped voltage, but I still get jumps during these transition points.
  1 Commento
Mathieu NOE
Mathieu NOE il 11 Dic 2023
hi
it would be nice to have data + maybe a picture that would help understand the issue

Accedi per commentare.

Risposte (1)

Akshat Dalal
Akshat Dalal il 18 Dic 2023
Hi Spencer,
I understand that you are getting circular data which could be represented as either degrees or radians, and you want to unwrap it to a linear scale.
I went through your code for manual unwrapping and I believe your changes to 'Ch0NumberOfCycles' are getting cascaded in the code. For example,
  1. Lets say your current iteration in the data is increasing, i.e Channel0BinaryDataNewTimeBase(i) - Channel0BinaryDataNewTimeBase(i-1) > 0.
  2. Now at the jump point, the data would jump from 4.5 to 0.5, i.e Channel0BinaryDataNewTimeBase(i) - Channel0BinaryDataNewTimeBase(i-1) < 0 and it would hit the first if condition, and 'Ch0NumberOfCycles' would be incremented along with Channel0BinaryDataNewTimeBase(i), making it greater than 4.
  3. Now consider Channel0BinaryDataNewTimeBase(i+1), since your data is circular and there was a jump point at Channel0BinaryDataNewTimeBase(i), Channel0BinaryDataNewTimeBase(i+1) will also be around the old value of Channel0BinaryDataNewTimeBase(i), i.e, 0.5.
  4. Thus, this will again create a jump point and you will again go into the else part of your if condition, incrementing 'Ch0NumberOfCycles' again, causing a cascading effect.
If you would like to manually unwrap your data, I suggest you to modify your code in the following way:
  1. Once you encouter a jump point, cache your changes to Channel0BinaryDataNewTimeBase until the next jump point.
  2. At the next jump point, apply your cached changes to the original data and follow the same steps till end of data.
This would remove the unnecessary cascading to 'Ch0NumberOfCycles'.
Hope this helps!

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by