# Split column in table based on character

6 visualizaciones (últimos 30 días)
Dion Theunissen el 3 de Ag. de 2021
Comentada: Walter Roberson el 3 de Ag. de 2021
Hi,
I have a table with a string column. Now i want to split this column in 3 seperate coluns.
In that column are strings like this:
["51∞ 13' 51,6""]
I want to create new columns like:
[51],[13], [51.6]
Anyone who can help me with this?
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Walter Roberson el 3 de Ag. de 2021
S = "51∞ 13' 51,6"""
S = "51∞ 13' 51,6""
str2double(regexp(regexprep(S, ',', '.'),'[\d.]+', 'match'))
ans = 1×3
51.0000 13.0000 51.6000
Is it possible for + or - to appear? How is N vs S or E vs W denoted?
##### 3 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
Dion Theunissen el 3 de Ag. de 2021
I have some issues with converting the values into a double or table. If I convert it to a double, i got NaN's. If I convert it to a table it results in 3 values and coluns in 1 column.
Walter Roberson el 3 de Ag. de 2021
S = [
"51∞ 14' 12,9"""
"51∞ 8' 40,2"""
"51∞ 16' 43,3"""
"51∞ 8' 40,3"""
]
S = 4×1 string array
"51∞ 14' 12,9"" "51∞ 8' 40,2"" "51∞ 16' 43,3"" "51∞ 8' 40,3""
cell2mat(cellfun(@str2double,regexp(regexprep(S, ',', '.'),'[\d.]+', 'match'), 'uniform', 0))
ans = 4×3
51.0000 14.0000 12.9000 51.0000 8.0000 40.2000 51.0000 16.0000 43.3000 51.0000 8.0000 40.3000

Iniciar sesión para comentar.

### Categorías

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

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by