diff m-toolbox/test/test_phasetrack.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/test/test_phasetrack.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,49 @@
+function test_phasetrack()
+% TEST_PHASETRACK tests phasetrack()
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: test of phasetracking for atan()-output
+%
+%
+% CALL:    test_phasetrack;
+%
+% HISTORY: 16-05-2008 Monsky
+%             Creation.
+%
+% VERSION: % $Id: test_phasetrack.m,v 1.1 2008/05/21 09:53:46 anneke Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Create tsdata with a sinewave
+pl = plist();
+pl = append(pl, param('fs', 100));
+pl = append(pl, param('nsecs', 5));
+pl = append(pl, param('waveform', 'sine wave'));
+pl = append(pl, param('f', 0.2));
+pl = append(pl, param('phi', 0));
+
+% Create an original time series with range bigger than +-PI
+original_data = 3*pi*ao(pl);
+
+% generate time series from original data as measured by phasemeter
+% if phasemeter uses atan() instead of atan2() for phase calculation
+
+pm_data=atan(tan(original_data));
+
+% apply phase tracking algorithm
+
+tracked_data=phasetrack(pm_data);
+
+iplot(original_data, pm_data, tracked_data, (original_data-tracked_data));
+legend 'original data' 'phasemeter output data' 'phase-tracked data' 'diff (original-tracked data)'
+
+plot(tracked_data.hist)
+% figure
+% subplot(2,2,1)
+% plot(original_data)
+% subplot(2,2,2)
+% plot(pm_data)
+% subplot(2,2,3)
+% plot(tracked_data)
+% subplot(2,2,4)
+% plot((original_data-tracked_data))