Separate one column of in a multi-column, (which is itself a cell array) into two columns in the existing cell array
Mostrar comentarios más antiguos
I have an application that reads data (from someone else's code), in a cell array with 8 columns. Here is a snipped of the first 9 rows:
9×8 cell array
Columns 1 through 6
{'E100M000.txt'} {'6109'} {'23-Sep-2020 14:…'} {[0.04]} {1×2 cell} {[4]}
{'E100M001.txt'} {'6109'} {'23-Sep-2020 14:…'} {[0.05]} {1×2 cell} {[4]}
{'E100M002.txt'} {'4781'} {'23-Sep-2020 15:…'} {[5.08]} {1×2 cell} {[0]}
{'E100M003.txt'} {'4717'} {'23-Sep-2020 15:…'} {[3.36]} {1×2 cell} {[0]}
{'E100M004.txt'} {'4781'} {'23-Sep-2020 15:…'} {[5.04]} {1×2 cell} {[0]}
{'E100M005.txt'} {'6051'} {'23-Sep-2020 16:…'} {[5.08]} {1×2 cell} {[0]}
{'E100M006.txt'} {'4167'} {'23-Sep-2020 15:…'} {[ 3.6]} {1×2 cell} {[0]}
{'E100M007.txt'} {'6022'} {'23-Sep-2020 15:…'} {[0.26]} {1×2 cell} {[0]}
{'E100M008.txt'} {'6002'} {'23-Sep-2020 16:…'} {[2.92]} {1×2 cell} {[0]}
Columns 7 through 8
{[2971.6]} {'Pleasant Valley…'}
{[3523.4]} {'Pleasant Valley…'}
{[ 0]} {'Peckham Propert…'}
{[ 0]} {'251 Creek Road' }
{[ 0]} {'Peckham Propert…'}
{[ 0]} {'23 Plateau Road' }
{[ 0]} {'Peckham Propert…'}
{[ 0]} {'Peckham Propert…'}
Column 5 is itself a cell array, and I would like to replace this with two columns in a new cell array of everything. Column 5 has a letter in the first column of the array, and a number in the second. Simple to split this? reshape? split? ???
Wish I could get it in the right format in the first place, no such luck.
Thanks!
Doug Anderson
1 comentario
Arif Hoq
el 23 de Mzo. de 2022
as you did not attach your data, you can try this
% A is your cell array
col5=A{:,5}
out=horzcat(A(:,1),A(:,2),A(:,3),A(:,4),col5,A(:,6),A(:,7),A(:,8),A(:,9))
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!