post:lienarlisephi.m

linearisePhi.m

Class: Function

Description: Calculates and inserts the fullPhi field of procTracks. fullPhi is based on phi, but has had increments of 180 degrees added and subtracted to allow you to smoothly keep track of a single pole.

Author: Oliver J. Meacock

linearisePhi.m
function procTracks = linearisePhi(procTracks)
%LINEARISEPHI takes the phi field of the input version of procTracks
%(defined nematically, so between -90 and 90) and adds or subtracts
%increments of 180 to each position in the track to ensure phi keeps track
%of a single pole.
%
%   INPUTS:
%       procTracks: The output of the tracking module of FAST, stored in
%       the 'Tracks.mat' file.
%
%   OUTPUTS:
%       procTracks: Version of procTracks with a new 'fullPhi' field, which
%       contains the wrapped version of phi.
%
%   Author: Oliver J. Meacock, (c) 2019
 
for i = 1:size(procTracks,2)
    phiDiff = diff(procTracks(i).phi);
    stepsUp = phiDiff < -90;
    stepsDown = phiDiff > 90;
    intSteps = cumsum(stepsUp - stepsDown);
    intSteps = [0; intSteps];
    procTracks(i).fullPhi = procTracks(i).phi + intSteps*180;
end

Example usage:

  %Apply the linearisePhi function to a given procTracks structure
  procTracks = linearisePhi(procTracks);
 
  %Plot phi before and after linearisation
  plot(procTracks(155).phi)
  hold on
  plot(procTracks(155).fullPhi)
 
  xlabel('Time')
  ylabel('Phi (degrees)')
 
  legend('phi','fullPhi')

Example output:

  • post/lienarlisephi.m.txt
  • Last modified: 2019/12/16 17:36
  • by pseudomoaner