Selecting part of a string
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have a list of file names in a variable called file_name e.g:
[a.txt b.txt c.txt d.txt]
I would like to create a new variable which only contains:
[a b c d]
Is this possible?
Thanks in advance Matt
3 comentarios
Paulo Silva
el 14 de Jun. de 2011
You say 4 rows and 1 column but your example is 4 columns and 1 row
Respuesta aceptada
Paulo Silva
el 14 de Jun. de 2011
surely not the best way to do it but here is my way
v=['a.txt' 'b.txt' 'c.txt' 'd.txt']
cell2mat(arrayfun(@(x)strtok(x,'.txt'),v,'uni',false))
or
v=['a.txt' 'b.txt' 'c.txt' 'd.txt']'
cell2mat(arrayfun(@(x)strtok(x,'.txt'),v,'uni',false))
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!