Unwrap function not operating correctly

B = (:,1:3);
C = (:,4); % Group packets restart at 0 and finish at a specific number
group = cumsum(C == 0) + double(C(1) ~= 0); % Splits the groups further
% into ones then twos then therees etc...
% [1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 4 4 4]'
Bb = splitapply(@(m) {(unwrap(m/2^15*pi)*2^15/pi)}, B, group); % Splits the groups up and performs the
% caculation unwrap(m/2^15*pi)*2^15/pi
Original output input at B
The result of the algorithm can be seen below. Unfortunately, it is not operating correctly as it has a drift in the y-direction. Can anyone provide any insight into how to correct this code?

4 个评论

What's the difference between the A used in the splitapply and the B you're talking about (not used in the splitapply).
Example data would be useful.
Sorry that should be B I corrected it.
Example data:
% This is one group
C =[2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2];
B1 =[-29486;-31150;-31500;-30576;-29350;-19632;-24221;-20417;-15841;-11325;-6617;5820;4186;10610;16942;22828;28142;-25680;-29776;-27538;-26586;-26958;-28566;-24044;31398;28060;23746;18618;12744;13482;-32574;-29124;-24850;-19676;-14163;-1173;19956;21032;21166;20836;20613;26955;17893;15253;11699;7629;2945;5079];
B2 =[-14395;-16584;-15732;-11954;-6460;2777;9769;19115;28455;-29054;-22624;-16542;-15596;-14866;-16418;-20092;-25514;-30488;26302;18940;12362;7056;3710;4162;4799;9249;15213;22089;29161;-28100;-7633;-10188;-10056;-7380;-2508;5849;-24876;-27404;-32100;27292;20888;15506;6928;266;-5541;-10183;-13225;-12943];
B3 =[26064;17076;7469;-2122;-10894;-13942;-23308;-26392;-27028;-24904;-20794;-10792;-8302;-1378;5287;10919;15055;21602;17542;15678;12180;7030;762;-1701;-12693;-18910;-23640;-26508;-27304;-21836;12621;5679;-1844;-9298;-15986;-17132;-788;7053;14501;20730;25130;31850;28062;26436;23402;19336;14472;13446];
B = [B1,B2,B3];
figure (1)
plot(B)
group = cumsum(C == 0) + double(C(1) ~= 0); % Splits the groups further
% into ones then twos then therees etc...
% [1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 4 4 4]'
Bb = splitapply(@(m) {(unwrap(m/2^15*pi)*2^15/pi)}, B, group); % Splits the groups up and performs the
% caculation unwrap(m/2^15*pi)*2^15/pi
B_new = cell2mat(Bb);
figure (2)
plot(B_new)
Unless, I'm missing something, it seems to work correctly with your example data. This is the output I get:
R2019b (please enter your version to the right of the question).
Hello Guilaume, sorry in the figure I provided,
C =[2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;3;3;3;3;3;3;4;4;4;4;4;4;4;4;4;4;4;4]
To break it up further.
Regarding the values the yellow and blue data lines should not surpass +-60000. The red you have plotted is correct, however the yellow and blue have drifted out of the range required. Thus, by splitting the values up further I got a something solution closer to the truth but now the red value has drifted.
I have MATLAB R2019b for some reason it does not let me input it on the web page.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by