フィルターのクリア

how to combine 2 columns together?

1 回表示 (過去 30 日間)
andrew
andrew 2014 年 2 月 12 日
編集済み: Azzi Abdelmalek 2014 年 2 月 12 日
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.

採用された回答

Azzi Abdelmalek
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 件のコメント
andrew
andrew 2014 年 2 月 12 日
column 1 is a cell array but column 2 is a double.
Azzi Abdelmalek
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
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.

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by