Remove and clear things in a table for presentation

조회 수: 46 (최근 30일)
Martin
Martin 2018년 3월 15일
댓글: dpb 2021년 6월 24일
I have a table like this:
T = 2x3 table
percent cars cats
________ _________________ _____________________
'59%' 'hej' 'nej'
[] '42405' '26211'
I would like this to look like this
percent cars cats
________ _________________ _____________________
59% hej nej
42405 26211
Removing [] and ' '. Is there any possible way to achieve this ?
Thanks in advance

채택된 답변

Peter Perkins
Peter Perkins 2018년 3월 23일
Martin, the display you get for a table is aimed at showing the data in the same way as those variables would be shown if they were not in a table. It sounds like you are looking for something more towards to presentation graphics.
If you converted all of your (I think) cellstr variables to char, you'd be closer to what you want, except for the {}. Perhaps you could (temporarily?) change those values to '[]'?
>> table(["a";"b"],{'a';'b'},['a';'b'])
ans =
2×3 table
Var1 Var2 Var3
____ ____ ____
"a" 'a' a
"b" 'b' b

추가 답변 (1개)

Walter Roberson
Walter Roberson 2018년 3월 15일
"Is there any possible way to achieve this"
Copy all of toolbox/matlab/datatypes/@tabular into your own directory that is earlier on the path. Modify the disp.m of your hacked version:
  1. change fullChar to default to true near line 30
  2. near line 160, change the scalar string case to not add double-quotes
  3. near line 320, change the quote characters to empty
  4. test thoroughly, because chances are that somewhere there is code that relies upon those quote marks being there
Note: You asked about "any possible way", not any practical way. If you had asked about practical ways, I would have said NO.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by