フィルターのクリア

when the result of strmatch has no value, then how can I change it to 0?

1 回表示 (過去 30 日間)
병주 김
병주 김 2022 年 3 月 3 日
編集済み: David 2022 年 3 月 3 日
I would like to search certain value for example 'parameter A'.
But parameter A is sometimes included but sometimes not included in texts what I'd like to check.
and the function I seach it is strmatch because it simply indicate the number of string where parameter A is included.
So I would like to use 'if' as below.
for i=1:handles.fn
aa.aa(i) = strmatch('parameter A', data(i));
if ~isnan(aa.aa(i))
aa.bb(i) = 1
else aa.bb(i) = 0
end;
end;
But failed as like below, in case data(3).embi has no 'parameter A'.
aa =
struct with fields:
aa: [503 499]
bb: [1 1]
Unable to perform assignment because the left and right sides have a different number of elements.
How can I handle this?? I mean how can I make bb has '0' when data has no 'parameter A'??

採用された回答

KSSV
KSSV 2022 年 3 月 3 日
REad about contains. You may use them. Also have a look on strcmp.

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by