Initial commit
[pftoolbox.git] / expressions / @xltv / private / num2str2.m
blob669527bb8a6e16ed2a83a78c076e32d2ca01a983
1 function str=num2str2(A);\r
2 % Converts a double to a single-line string.\r
3 \r
4 % Toolbox for nonlinear filtering.\r
5 % Copyright (C) 2005  Jakob Rosén <jakob.rosen@gmail.com>\r
6 %\r
7 % This program is free software; you can redistribute it and/or\r
8 % modify it under the terms of the GNU General Public License\r
9 % as published by the Free Software Foundation; either version 2\r
10 % of the License, or (at your option) any later version.\r
11 %\r
12 % This program is distributed in the hope that it will be useful,\r
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 % GNU General Public License for more details.\r
16 %\r
17 % You should have received a copy of the GNU General Public License\r
18 % along with this program; if not, write to the Free Software\r
19 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
21 m=size(A,1);\r
22 n=size(A,2);\r
24 if isempty(A)\r
25         % Empty double\r
26         str='[]';\r
27 elseif m==1&&n==1\r
28         % Scalar. Don't use '[' and ']'\r
29         str=num2str(A);\r
30 else\r
31         str='[';\r
32         for j=1:m\r
33                 str=[str, num2str(A(j,:)), '; '];\r
34         end;\r
35         str=str(1:end-2);\r
36         str=[str,']'];\r
38         % Remove consequtive spaces\r
39         temp=[];\r
40         while ~strcmp(str,temp)\r
41                 temp=str;\r
42                 str=strrep(str,'  ',' ');\r
43         end\r
45 end\r