Borrar filtros
Borrar filtros

Read set framents of string.

3 visualizaciones (últimos 30 días)
Jonasz
Jonasz el 14 de Ag. de 2013
I have a lot of strings and I want only to read part of them and write to variable value of the string example :
abcdefghR12X478Y124
I need to read a coordinates of this file
so X - 478
and Y - 124
what is the best way to extract it from the file name and write to X variable and Y variable.

Respuesta aceptada

Evan
Evan el 14 de Ag. de 2013
Editada: Evan el 14 de Ag. de 2013
>> s = 'abcdefghR12X478Y124';
>> X = str2double(regexp(s,'(?<=X)\d+','match'))
X =
478
>> Y = str2double(regexp(s,'(?<=Y)\d+','match'))
Y =
124
  2 comentarios
Jonasz
Jonasz el 14 de Ag. de 2013
Thank You very much !
Evan
Evan el 14 de Ag. de 2013
No problem! :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by