creating a list from another list
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a list where not all the elements are the same length but they mostly are lets say my list is
mylist = {'ABCD', 'DEFG', 'HIJKL'} i want to return a new list mynewlist looks like {ABC, DEF, GHI} %%- its always the first 3 letters of the old list
many thanks probably seems a bit arbtirary but struggling
0 comentarios
Respuesta aceptada
Azzi Abdelmalek
el 8 de Mzo. de 2013
mylist = {'ABCD', 'DEFG', 'HIJKL'}
out=cellfun(@(x) x(1:3),mylist,'un',0)
0 comentarios
Más respuestas (1)
per isakson
el 8 de Mzo. de 2013
>> mylist = {'ABCD', 'DEFG', 'HIJKL'}
mylist =
'ABCD' 'DEFG' 'HIJKL'
>> cellfun( @(str) str(1:3), mylist, 'uni', false )
ans =
'ABC' 'DEF' 'HIJ'
>>
Ver también
Categorías
Más información sobre Data Type Conversion 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!