dpb <firstname.lastname@example.org> wrote in message <email@example.com>... > On 11/21/2012 7:41 AM, Amin Bashi wrote: > > Hi everyone > > I recently observed strange behavior of num2str function. As you see in > > below: > >>> c = [1 2; 3 4] > > > > c = > > > > 1 2 > > 3 4 > > > >>> double(num2str(c(1,:))) > > > > ans = > > > > 49 32 32 50 > > > > Obviously it put space between 1 and 2; > > what can i do to solve this problem? > > If you want a specific format, specify that format. num2str() converts > numeric values in a "pretty" format over which you have very little > control other than a precision. > > Use sprintf() instead-- > > double(sprintf('%d',c(1,:)) > > --
Thanks. But I don?t remember this side effect on older MATLAB versions. this is a better trick to solve the problem: num2str(c(1,:)')'