Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
병주 김
병주 김 le 3 Mar 2022
Modifié(e) : David le 3 Mar 2022
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'??

Réponse acceptée

KSSV
KSSV le 3 Mar 2022
REad about contains. You may use them. Also have a look on strcmp.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by