Write values from 3 columns into one column
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Vespi
el 13 de Mzo. de 2016
Respondida: Star Strider
el 13 de Mzo. de 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 comentarios
Respuesta aceptada
Star Strider
el 13 de Mzo. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!