Hello,
I have a table with the example values below:
prev1 prev2 prev3
0 0 0
1 0 0
1 1 0
2 1 1
1 2 1
2 1 2
2 2 1
2 2 2
2 2 2
1 2 2
I am looking to combine the cases across columns to make a new column that will now have values like this:
000
100
110
211
121
212
221
222
122
Any thoughts?

 채택된 답변

dpb
dpb 2015년 1월 8일

1 개 추천

>> num2str(x.','%1d').'
ans =
000
100
110
211
121
212
221
222
222
122
>> whos ans
Name Size Bytes Class Attributes
ans 10x3 60 char
>>
returns a character array of length(x), each row of which is the desired string representation.

댓글 수: 1

Thanks, I used your suggestion in the code below to get it to work.
tabm.previous3 = strcat((num2str(tabm.prev1','%1d').'),(num2str(tabm.prev2','%1d').'),(num2str(tabm.prev3','%1d').'));

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numeric Types에 대해 자세히 알아보기

질문:

2015년 1월 8일

댓글:

2015년 1월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by