printing columns next to each other

3 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2017-11-19
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]')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by