필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

having problem to call m.file

조회 수: 1 (최근 30일)
Ana Royce
Ana Royce 2016년 8월 15일
마감: MATLAB Answer Bot 2021년 8월 20일
please assist the below. exparx showing results = 0
exparx='expfun1cf1';
if exparx == 'expfun1cfd';
....
elseif exparx == 'expfun1cf1';
...
end

답변 (2개)

Walter Roberson
Walter Roberson 2016년 8월 15일
Use strcmp() to compare strings.

Thorsten
Thorsten 2016년 8월 15일
You can use switch to compare a string variable to different other constant strings:
switch exparx
case 'expfun1cfd'
% do some stuff
case 'expfun1cf1'
% do some other stuff
end
  댓글 수: 1
Guillaume
Guillaume 2016년 8월 15일
You can use switch to compare a string ...
... which uses strcmp to do the comparison. As per Walter's answer, string comparison must be done with strcmp, never with ==.
If you want to have several branches depending on the value of the string, then indeed using switch as per Thorsten's answer may be more elegant than several if strcmp ... else if strcmp ...

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by