Home > m > helper > ltpda_mat2str.m

ltpda_mat2str

PURPOSE ^

LTPDA_MAT2STR overloads the mat2str operator to set the precision at a central place.

SYNOPSIS ^

function str = ltpda_mat2str(number)

DESCRIPTION ^

 LTPDA_MAT2STR overloads the mat2str operator to set the precision at a central place.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: LTPDA_MAT2STR overloads the mat2str operator to set the
              precision at a central place.

 CALL:        str = ltpda_mat2str(number);
              str = ltpda_mat2str(matrix);

 VERSION:     $Id: ltpda_mat2str.html,v 1.12 2008/03/31 10:27:31 hewitson Exp $

 HISTORY:     26-07-2007 Diepholz
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function str = ltpda_mat2str(number)
0002 % LTPDA_MAT2STR overloads the mat2str operator to set the precision at a central place.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: LTPDA_MAT2STR overloads the mat2str operator to set the
0007 %              precision at a central place.
0008 %
0009 % CALL:        str = ltpda_mat2str(number);
0010 %              str = ltpda_mat2str(matrix);
0011 %
0012 % VERSION:     $Id: ltpda_mat2str.html,v 1.12 2008/03/31 10:27:31 hewitson Exp $
0013 %
0014 % HISTORY:     26-07-2007 Diepholz
0015 %                 Creation
0016 %
0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0018 
0019 MAX_PRECISION = 20;
0020 
0021 s = size(number);
0022 if s(1) ~= 1 && s(2) ~= 1
0023   str = mat2str(number, MAX_PRECISION);
0024 
0025 elseif isreal(number)
0026 
0027   % For vectors it is faster to use sprintf directly
0028   if s(1) ~= s(2)
0029     str = '[';
0030   else
0031     str = '';
0032   end
0033   if s(1) > s(2)
0034     str = [str sprintf('%.17g;', number)];
0035   else
0036     str = [str sprintf('%.17g ', number)];
0037   end
0038   if s(1) ~= s(2)
0039     str = [str(1:end-1) ']'];
0040   else
0041     str = str(1:end-1);
0042   end
0043 
0044 else
0045   str = mat2str(number, MAX_PRECISION);
0046 end
0047 
0048 
0049

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003