view m-toolbox/classes/@ao/fixAxisData.m @ 15:ce3fbb7ebe71 database-connection-manager

Remove broken functions from utils.jmysql
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +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