Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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'??

Respuesta aceptada

KSSV
KSSV el 3 de Mzo. de 2022
REad about contains. You may use them. Also have a look on strcmp.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by