フィルターのクリア

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.
  1 件のコメント
kintali narendra
kintali narendra 2017 年 3 月 7 日
Thank you sir,it worked perfectly.

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

その他の回答 (0 件)

カテゴリ

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