MATLAB: Selecting part of a string

modifying a string

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

Best Answer

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))