フィルターのクリア

Write values from 3 columns into one column

3 ビュー (過去 30 日間)
Vespi
Vespi 2016 年 3 月 13 日
回答済み: Star Strider 2016 年 3 月 13 日
I would like to merge 3 column values into one column as can be done in execl. For example, I have column values C1-C3 and I want to create column C4 as shown below:
C1 C2 C3 C4
1 2 3 123
4 5 7 457
19 4 25 19425
I tried A(:), but my values are not written as shown in C4 above. Can this be done in MatLab?

採用された回答

Star Strider
Star Strider 2016 年 3 月 13 日
The only way I can think of to do it is:
A = [1 2 3
4 5 7
19 4 25];
Out = str2num(sprintf([repmat('%d',1,size(A,2)) '\n'], A'))
Out =
123
457
19425
If you want to concatenate ‘Out’ with ‘A’:
Anew = [A Out]
Anew =
1 2 3 123
4 5 7 457
19 4 25 19425

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by