Hello.
I have matrix with complex numbers with different numbers of digits. I want to print them to the file but they are not aligned.
|1.00+0.00i 1.00+0.00i 1.00+0.00i 1.00+0.00i| |0.00+0.00i -49.00+4.00i -49.00-4.00i -52.00+0.00i| |0.00+0.00i -2417.00-0.00i -2417.00+0.00i -2392.00+0.00i| |0.00+0.00i -117649.00-64.00i -117649.00+64.00i -117676.00+0.00i|
I need something like this:
|1.00+0.00i 1.00+0.00i 1.00+0.00i 1.00+0.00i| |0.00+0.00i -49.00+4.00i -49.00-4.00i -52.00+0.00i| |0.00+0.00i -2417.00-0.00i -2417.00+0.00i -2392.00+0.00i| |0.00+0.00i -117649.00-64.00i -117649.00+64.00i -117676.00+0.00i|
This is code that I print it into file
for k=1:n fprintf(fileID,' |%.2f%+.2fi %.2f%+.2fi %.2f%+.2fi %.2f%+.2fi|\r\n',[real(A(k,:));imag(A(k,:))]); end fprintf(fileID, '\r\n\r\n\r\n');
Is there any way to make this matrix more aligned?
Best Answer