Azzera filtri
Azzera filtri

printing columns next to each other

3 visualizzazioni (ultimi 30 giorni)
i have 4 arrays
a=[1;2;3] b=[4;5;6] c=[7;8;9] d=[10;11;12]
fileid=fopen('saving.txt','w'); fprintf(fileid,'%6s %12s %14s %16s\r\n','Enrgy','countrate','FWHM','Resolution');
fprintf(fileid,'%6.4f %12.4f %14f %16f\n',a, b,c,d); i want to print each column next to each other like:
1 4 7 10
2 5 8 11
3 5 9 12
but i showed like this
Enrgy countrate FWHM Resolution
1.0000 2.0000 3.000000 4.000000
5.0000 6.0000 7.000000 8.000000
9.0000 10.0000 11.000000 12.000000
so please any help

Risposta accettata

Star Strider
Star Strider il 19 Nov 2017
You need to concatenate the variables into a matrix, then transpose the matrix:
fprintf(fileid, '%6.4f %12.4f %14f %16f\n',[a,b,c,d]')

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by