read part of string
Mostrar comentarios más antiguos
I have mat file like 'name.mat'
name(1,1) = Italy
name(2,1) = Rome, Italy
And I want to get 'Rome'.
I do not know the function that I want.
Please help me.
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 12 de Jul. de 2014
name = {'Italy'; 'Rome, Italy'} % Cell array. Use braces not parentheses.
words = allwords(name{2,1}) % words = 'Rome' 'Italy'
Or simply use normal indexing as usual to extract the first 4 characters of the contents of the second cell:
rome = name{2,1}(1:4)
1 comentario
Image Analyst
el 12 de Jul. de 2014
Categorías
Más información sobre Language Support 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!