필터 지우기
필터 지우기

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 CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by