How to erase cell array element with less than three characters
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Damien Williams
el 7 de Mayo de 2019
Comentada: Davindra Usov
el 22 de Jun. de 2022
If i have a function that accepts a string of characters eg('cgugcaguca') and i use
cellArr = regexp(mRNA, sprintf('\\w{1,%d}',3),'match');
to arrange the string into a cell array grouped in threes, how do i erase any elements with less than three characters.
eg {'cgu'} {'gca'} {'guc'} {'a'} , i want to erase the cell with 1 character.
1 comentario
Stephen23
el 7 de Mayo de 2019
Just specify the regular expression to only return groups of that number:
>> mRNA = 'cgugcaguca';
>> regexp(mRNA,sprintf('\\w{%d}',3),'match')
ans =
'cgu' 'gca' 'guc'
Respuesta aceptada
KSSV
el 7 de Mayo de 2019
C = [{'cgu'} {'gca'} {'guc'} {'a'}] ;
L = cellfun(@length,C) ; % GEt length of each cell array
C(L<3) = [] % Remove cell's whose length is less than 3
2 comentarios
Davindra Usov
el 22 de Jun. de 2022
Hi, do you happen to know how I can remove all string/chars from a 4x10 cell array where each cell in that array contains a 40x1 column vector? (so as you can see, it's nested). Thank you :)
Más respuestas (0)
Ver también
Categorías
Más información sobre Cell Arrays 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!