Write values from 3 columns into one column
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vespi
le 13 Mar 2016
Réponse apportée : Star Strider
le 13 Mar 2016
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?
0 commentaires
Réponse acceptée
Star Strider
le 13 Mar 2016
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!