필터 지우기
필터 지우기

printing columns next to each other

조회 수: 3 (최근 30일)
Rashid Hussein
Rashid Hussein 2017년 11월 19일
댓글: Sara Pierson 2021년 4월 1일
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]')
  댓글 수: 1
Sara Pierson
Sara Pierson 2021년 4월 1일
That does not work matlab 2020b unfortunately

댓글을 달려면 로그인하십시오.

추가 답변 (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