Generating a table with text
이전 댓글 표시
Hello Community,
I have a question about the command to generate a table with several variables. I have 5 arrays and one is a text array.
I want to join the 5 arrays into 1 table. However, for some reason the text array place ' ' symbols on each text. In other words, A(a b c ...,1) B(1 2 3 ...,1) C(1 2 3 ...,1) etc. the results ABCDE_Table=table(A,B,C,D,E) but by opening the ABCDE_Table I realize that column A has been modified by ABCDE_Table(:,1)=('a' 'b' 'c' ....,1).
How do I remove ' ' or import the text with out ' '?
Thanks for your time
채택된 답변
추가 답변 (1개)
Walter Roberson
2017년 8월 24일
You cannot change that. It is the way that the display function is defined for tables. MATLAB often displays '' around text. For example,
>> test.dat = 'aaa'
test =
struct with fields:
dat: 'aaa'
You have to understand that table objects are not designed for output layout: they are designed for manipulating tabular data of mixed data types. There is almost no format control for them.
If you need to output in text form without the '' marks, then you need to write your own output routines, perhaps converting the table contents into a cell array and then using a careful fprintf() format.
댓글 수: 1
Ernest Modise - Kgamane
2021년 3월 24일
Thank for your answer to the original question,
I wanted to use the same approach to create a table like
0 00
1 01
2 11
3 101
4 1001
5 10001
6 100001
where 0 - 6 are the table index in numerics, and 00 to 100001 are some binary code I want to be a string.
Now using your code below if I print T.A{1}
My results come with quotes,
For my application I want for example to output a concatenated string say for index 3 and index 1 in that order,
i.e. 10101
for the example above, the code below will output '101''01'
Please help on how I can resolve this.
> A = {'a','b'}';
>> B = {1,3}';
>> T = table(A,B);
>> disp(T)
A B
_____ _____
{'a'} {[1]}
{'b'} {[3]}
>> T.A{1}
ans =
'a'
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!