view m-toolbox/classes/@ao/fixAxisData.m @ 2:18e956c96a1b database-connection-manager

Add LTPDADatabaseConnectionManager implementation. Matlab code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Sun, 04 Dec 2011 21:23:09 +0100
parents f0afece42f48
children
line wrap: on
line source

% 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