필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by