-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecentrePhase.m
More file actions
23 lines (22 loc) · 784 Bytes
/
recentrePhase.m
File metadata and controls
23 lines (22 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function phaseData = recentrePhase(phaseData, phaseCentre)
% phaseData = recentrePhase(phaseData, phaseCentre)
%
% Function converts phase values to values within a chosen phase range
% centred around input variable phaseCentre: [phaseCentre-pi
% phaseCentre+pi].
% Input: phaseData - a vector or a matrix of phase values.
% phaseCentre - the centre of the new phase range.
% Output: phaseData - recentred phase data.
upperLimit = phaseCentre + pi;
lowerLimit = phaseCentre - pi;
for i = 1:numel(phaseData)
if phaseData(i) > upperLimit
while phaseData(i) > upperLimit
phaseData(i) = phaseData(i) - 2*pi;
end
elseif phaseData(i) < lowerLimit
while phaseData(i) < lowerLimit
phaseData(i) = phaseData(i) + 2*pi;
end
end
end