view m-toolbox/classes/@ao/fixAxisData.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +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