フィルターのクリア

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