how to combine 2 columns together?
조회 수: 2 (최근 30일)
이전 댓글 표시
I would like to combine 2 columns together with a , in between the columns. for example column 1 has 0% and column 2 has 1.0 and the final result should be 0%,1.0.
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2014년 2월 12일
편집: Azzi Abdelmalek
2014년 2월 12일
A={'0%';'1%';'2%'}
B={'1.0';'2.0';'3.0'}
out=strcat(A,B)
If your data are different from what I posted, then clarify your question
댓글 수: 2
Azzi Abdelmalek
2014년 2월 12일
편집: Azzi Abdelmalek
2014년 2월 12일
A={'0%';'1%';'2%'}
B=[1;2;3]
C=arrayfun(@(x) sprintf(',%.1f',x),B,'un',0)
out=strcat(A,C)
추가 답변 (1개)
dpb
2014년 2월 12일
You'll have to do this w/ a specific format...
>> fprintf('%d%%,%.1f\n',x')
0%,1.0
>>
While I used a 2-element vector, NB that you'll have to transpose an array to write in row-major order for output.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!