From: chanpreet kaur on
HI all

I want to write two matrices a and b in text file such that a and b are printed one after other with empty row in between them
i am using this command

dlmwrite(f, a, 'delimiter', '\t','precision', 6)
dlmwrite(f, b , '-append', 'roffset', 1 ,'delimiter', '\t','precision', 6)

The problem with this code is that the empty row between a and b which is obtained has two tabs and one enter. I need only enter in that row and no tabs.

If some bode can help
Thanks in advance
Kind Regards
rimi
From: Walter Roberson on
chanpreet kaur wrote:
> HI all
>
> I want to write two matrices a and b in text file such that a and b are
> printed one after other with empty row in between them
> i am using this command
>
> dlmwrite(f, a, 'delimiter', '\t','precision', 6)
> dlmwrite(f, b , '-append', 'roffset', 1 ,'delimiter', '\t','precision', 6)
>
> The problem with this code is that the empty row between a and b which
> is obtained has two tabs and one enter. I need only enter in that row
> and no tabs.

Don't use dlmwrite() to write the empty line: use fwrite() or fprintf() to
write the empty line.

Possibly the equivalent to your code is:

fprintf(f, [repmat('%.6f\t', 1, size(a,2), '%.6f\n'], a .' );
fprintf(f, '\n');
fprintf(f, [repmat('%.6f\t', 1, size(b,2), '%.6f\n'], b .' );

I would need, though, to double-check whether the precision argument
corresponds to %.6f or to %.6g or to %10.6e.