Borrar filtros
Borrar filtros

Write values from 3 columns into one column

3 visualizaciones (últimos 30 días)
Vespi
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?

Respuesta aceptada

Star Strider
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

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by