Mercurial > hg > ltpda
view m-toolbox/classes/@cdata/rdivide.m @ 37:a4b7ceae0403 database-connection-manager
Show backtrace on unit test errors
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
% RDIVIDE implements element division for cdata objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DESCRIPTION: RDIVIDE implements element division for two cdata objects. % % CALL: % a = d1./d2 % a = rdivide(d1,d2); % % % <a href="matlab:utils.helper.displayMethodInfo('cdata', 'rdivide')">Parameters Description</a> % % VERSION: $Id: rdivide.m,v 1.2 2011/04/08 08:56:34 hewitson Exp $ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function varargout = rdivide(varargin) % get two data objects d1 = copy(varargin{1}, nargout); d2 = copy(varargin{2}, nargout); % check units d1.yunits.simplify(); d2.yunits.simplify(); % add the data dout = applyoperator(d1,d2,'rdivide'); % handle units: multiply the units dout.yunits = d1.yunits./d2.yunits; % handle errors err = @(err1, err2, val1, val2) sqrt( (err1./val1).^2 + (err2./val2).^2 ) .* abs(val1./val2); if ~isempty(d1.dy) || ~isempty(d2.dy) if isempty(d1.dy) d1.dy = zeros(size(d2.dy)); end if isempty(d2.dy) d2.dy = zeros(size(d1.dy)); end dout.dy = err(d1.dy, d2.dy, d1.y, d2.y); else dout.dy = []; end % Single output varargout{1} = dout; end