Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to divide a cell into two groups based on two types of strings
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I have a cell, say 20 by 1, which looks like below (ignore the 879). Each one in a cell is a string such as 'bad1.png'.
As you can see, some has the suffix of '.png' and some has the suffix of '.jpg'.
How can I separate them into two groups with one group only contains '.png' and the other group only contains '.jpg'?
Thanks!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/190993/image.png)
댓글 수: 0
답변 (1개)
Ameer Hamza
2018년 6월 3일
Try this
index = contains(names, '.png'); % nemes is your cell array
pngFiles = names(index);
jpgFiles = names(~index);
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!