Creating a Table with labels for each column

조회 수: 9 (최근 30일)
Thomas
Thomas 2013년 2월 28일
So I have this matrix that is set up like so
Column1 -----------Column 2----------Column 3
1 0 28.3784
2 0 30
3 0 22.7027
What I want to do is take this matrix and put it into a table and have those columns labeled. App Num for column 1, gender for column 2, and gpa for column 3. I also need to put a title on the table that describes what is going on. Any ideas?
Thank you for your time.
  댓글 수: 2
Thomas
Thomas 2013년 2월 28일
So I have this code but I can't seem to get the rows to line up
fprintf('\n\t\tAppNumb \t\tgender \t\tgpa \t\texp \t\tlines (bonus)'); fprintf('\n%11.4f %11.4f %11.4f %11.4f %11.4f %11.4f', With2'); fprintf('\n')
Jan
Jan 2013년 2월 28일
There is only a weak relation between the shown table and the posted code: It looks like the data have 6 columns, not three. And there are no '-' characters between the names in the header.

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

채택된 답변

Jan
Jan 2013년 2월 28일
Avoid the \t in the header line, because they do not have a fixed width. '%12s' is smarter, because it works like the width specificator in the '%12.4f' format string.
  댓글 수: 1
Thomas
Thomas 2013년 2월 28일
So it should look like this?
sprintf('\n\%12s\sAppNumb \%12s\sgender \%12s\sgpa \%12s\sexp \%12s\slines (bonus)'); fprintf('\n%11.0f %11.0f %11.4f %11.4f %11.4f %11.0f', With2'); fprintf('\n')

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Labels and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by