IF Statements - case sensitive

6 ビュー (過去 30 日間)
Allyson
Allyson 2014 年 2 月 28 日
コメント済み: Chad Greene 2014 年 2 月 28 日
I am writing an IF statement. The user is prompt to enter the word "play" to begin, how do I write it so it is not case sensitive. For example they could enter "Play" or pLay" or PLAy" and it would accept the word

回答 (1 件)

Chad Greene
Chad Greene 2014 年 2 月 28 日
Try the strcmpi function.
  1 件のコメント
Chad Greene
Chad Greene 2014 年 2 月 28 日
For example:
user_input = 'plAy';
if strcmpi(user_input,'play')
disp('the user has input the word play')
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeVariables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by