フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to divide a cell into two groups based on two types of strings

2 ビュー (過去 30 日間)
Salad Box
Salad Box 2018 年 6 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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!

回答 (1 件)

Ameer Hamza
Ameer Hamza 2018 年 6 月 3 日
Try this
index = contains(names, '.png'); % nemes is your cell array
pngFiles = names(index);
jpgFiles = names(~index);

この質問は閉じられています。

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by