In MATLAB I'm printing a very large matrix this way:
fid = fopen('c:\\OUTPUT.txt','wt');
fprintf(fid,'%f\t',T');
fclose(fid);
But this is not right! I want to print it like this:(\t
between them and \n
at the end of row)
1 2 3
4 5 6
7 8 9
10 11 12
I searched and found If it was 3*3 this was fine:
fprintf(fid,'%f %f %f\n',T');
But I in my case size change...
The most common way is to explicitly specify the indices of the elements. For example, to access a single element of a matrix, specify the row number followed by the column number of the element. e is the element in the 3,2 position (third row, second column) of A .
You may also want to look at dlmwrite
You can set delimiters, precision, etc.
dlmwrite('myfile.txt', M, 'delimiter', '\t', 'precision', 6)
Where M
is your matrix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With