Mercurial > hg > ltpda
view m-toolbox/classes/@unit/char.m @ 51:9d5c88356247 database-connection-manager
Make unit tests database connection parameters configurable
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 07 Dec 2011 17:24:37 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
% CHAR convert a unit object into a string. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DESCRIPTION: CHAR convert a unit object into a string. % % CALL: string = char(unit) % % VERSION: $Id: char.m,v 1.11 2011/02/18 16:48:55 ingo Exp $ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function str = char(v) str = ' '; for jj=1:numel(v) NDimensions = numel(v(jj).strs); if NDimensions == 0 nameString = '[]'; else nameString = ''; for nd = 1:NDimensions if(v(jj).exps(nd)~=0) prefix = unit.val2prefix(v(jj).vals(nd)); [n,d] = rat(v(jj).exps(nd)); if(d==1) if v(jj).exps(nd) ~=1 nameString = sprintf('%s[%s%s^(%g)]', nameString,prefix,v(jj).strs{nd},v(jj).exps(nd)); else nameString = sprintf('%s[%s%s]',nameString,prefix,v(jj).strs{nd}); end else nameString = sprintf('%s[%s%s^(%g/%g)]',nameString,prefix,v(jj).strs{nd},n,d); end else nameString = sprintf('%s[]',nameString); end end end str_loop = strrep(nameString, '][', ' '); str = [str, str_loop]; end str = strtrim(str); end