diff m-toolbox/classes/@ao/fixAxisData.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/classes/@ao/fixAxisData.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,44 @@
+% Fix up the data type according to the users chosen axis
+function bs = fixAxisData(bs, pl)
+  
+  % Set data
+  for ii =1:numel(bs)
+    
+    if (isa(bs(ii).data, 'cdata'))
+      if strfind(pl.find('axis'), 'x')
+        warning('### An AO with cdata doesn''t have a x-axis. Setting the axis to ''y''.');
+        pl.pset('axis', 'y');
+      end
+    else
+      xu = bs(ii).xunits;
+    end
+    
+    yu = bs(ii).yunits;
+    switch lower(pl.find('axis'))
+      case 'xy'
+        if bs(ii).data.isprop('x')
+          bs(ii).data = xydata(bs(ii).data.x, bs(ii).data.y);
+          bs(ii).data.setXunits(xu);
+          bs(ii).data.setYunits(yu);
+        else
+          error('### It is not possible to compute on the x-axis of an cdata object.')
+        end
+      case 'x'
+        if bs(ii).data.isprop('x')
+          bs(ii).data = cdata(bs(ii).data.x);
+          bs(ii).data.setYunits(xu);
+        else
+          error('### It is not possible to compute on the x-axis of an cdata object.')
+        end
+      case 'y'
+        bs(ii).data = cdata(bs(ii).data.y);
+        bs(ii).data.setYunits(yu);
+      otherwise
+        error('### shouldn''t happen.');
+    end
+    % Fix the history to what we actually return
+    bs(ii).hist.plistUsed.pset('axis', pl.find('axis'));
+  end
+  
+  
+end