How to erase cell array element with less than three characters
8 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Stephen23
2019 年 5 月 7 日
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'
採用された回答
KSSV
2019 年 5 月 7 日
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 件のコメント
Davindra Usov
2022 年 6 月 22 日
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 :)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!