フィルターのクリア

use of strmatch to find a string NOT at the start of a line

2 ビュー (過去 30 日間)
Matthew O'Brien
Matthew O'Brien 2011 年 8 月 9 日
Hi I have some data:
  1. PeakType Center Height Area FWHM parameters%_1 Linear x x x x 74.6852 -33.1093%_2 PseudoVoigt 0.728123 49.5433 1.78981 %_2 PseudoVoigt 0.728123 49.5433 1.78981
and this is stored is a cell array (in this case with a size of 4 and called 'everything'). now i can do the following to find the index of all occurrences of %_2:
findName = '%_2';
occurence = strmatch(findName,everything);
However what i need to do is simply find the index of where the string PseudoVoigt occurs (as it will not always start with %_2). I cannot use:
findName = 'PseudoVoigt';
occurence = strmatch(findName,everything);
Is there anyway i can do this without resorting to matlabs other strng matching functions and loops? If not then i think it would be very useful if this function could have an option to allow you to search in this way.
Thanks
Matt

採用された回答

Oleg Komarov
Oleg Komarov 2011 年 8 月 9 日
idx = strfind(everything,'PseudoVoigt')
idx = ~cellfun('isempty',idx)
idx is logical true whenever it finds PseudoVoigt in any part of the string.

その他の回答 (1 件)

Friedrich
Friedrich 2011 年 8 月 9 日
  1 件のコメント
Matthew O'Brien
Matthew O'Brien 2011 年 8 月 9 日
Thanks to both of you for the answer. The output is not exactly the same as you get empty values where the string is not found and rather than the index of the occurrence you get the index of the start position of the search string but i think that i can still use this.
Still it would be useful to have a switch on strmatch to do this and obtain the same output.

サインインしてコメントする。

カテゴリ

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