Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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'??

Akzeptierte Antwort

KSSV
KSSV am 3 Mär. 2022
REad about contains. You may use them. Also have a look on strcmp.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by