Keep Only Cells With a String Beginning with a Certain Letter

8 ビュー (過去 30 日間)
Calum
Calum 2014 年 10 月 24 日
編集済み: Adam 2014 年 10 月 24 日
If I have a data-set as follows:
['ABC'; 'ABC'; 'ABC'; 'DEF'; 'DEF'; 'DEF'; 'XYZ'; 'XYZ'; 'XYZ']
How do I only keep rows which contain a string beginning with the letter 'D'?
Regards,
CS

回答 (1 件)

Adam
Adam 2014 年 10 月 24 日
編集済み: Adam 2014 年 10 月 24 日
s = ['ABC'; 'ABC'; 'ABC'; 'DEF'; 'DEF'; 'DEF'; 'XYZ'; 'XYZ'; 'XYZ'];
s = s( s(:,1) == 'D',: );
assuming you stated the full complexity of the problem in your question.

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by