필터 지우기
필터 지우기

How to update comparison expression as the loop updates ?

조회 수: 2 (최근 30일)
kintali narendra
kintali narendra 2017년 3월 7일
댓글: kintali narendra 2017년 3월 7일
I need to update my comparison expression , I dont know how to do it. All my comparison expressions are stored in a cells.
stringDAT = 'bat cat can car coat Name CUT ct CAT-scan'
expression = 'Name'
startIndex = regexp(stringDAT,expression)
I want the comparison expression need to be updated.
for i = 1:10
expression = value(i)
startIndex = regexp(StringDAT,expression)
where value has 10 different characters stored in form of cell.
thanku all
  댓글 수: 2
KSSV
KSSV 2017년 3월 7일
What is comparison expression? You have to give an example, your question is not clear.
kintali narendra
kintali narendra 2017년 3월 7일
sir , in we use string stored in 'expression' to compare with the data in 'stringDAT' , my question is, How we will update the string in 'expression' as the loop updates. As I have many values to compare.

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2017년 3월 7일
stringDAT = 'bat cat can car coat Name CUT ct CAT-scan'
% expression = 'Name' ;
% startIndex = regexp(stringDAT,expression) ;
value = {'apple' 'bat' 'cat' 'dog' 'car' 'cut' 'CUT'} ;
startIndex = NaN(size(value)) ;
for i = 1:length(value)
expression = value{i} ;
idx = regexp(stringDAT,expression) ;
if ~isempty(idx)
startIndex(i) = idx ;
end
end
Note that NaN means there is no matching.

추가 답변 (0개)

카테고리

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