From octave-sources-request at bevo dot che dot wisc dot edu Mon Jul 21 07:34:13 2003 Subject: Re: num2str From: Fabian at isas-berlin dot de To: octave-sources at bevo dot che dot wisc dot edu Cc: M dot Jueschke at DPI dot Physik dot Uni-Goettingen dot de Date: Mon, 21 Jul 2003 03:53:57 -0500 > Since I didn't find a num2str for octave which handeles matrices and > complex numbers, I have written one. Function 'mat2str' from Octave-Forge ( 2003-June-2 ) handles complex matrices It has been also published as . 'mat2str' is vectorized ( no for-loops ) in contrast to 'num2str'. On my system, I get the following tictoc-times: :> N=200; x=randn(N)+randn(N)*i; :> tic; y=num2str(x); TICTOC_NUM2STR=toc TICTOC_NUM2STR = 22.0 sec :>> tic; y=mat2str(x); TICTOC_MAT2STR=toc TICTOC_MAT2STR = 4.07 sec i.e. 'mat2str' is 5.4 x faster than 'num2str' for the same 200x200 complex matrix input. In addition 'mat2str' encloses output string in a pair of brackets in order to make it siutable as 'eval' input and adds commas and semicolons to more clearly seperate matrix elements. As another plus, 'mat2str' allows to specify the number of decimals to be printed as an input argument. Rolf