How do i make input correct to be both lower and uppercase?

17 ビュー (過去 30 日間)
Kalpha.mc
Kalpha.mc 2020 年 11 月 17 日
回答済み: Ameer Hamza 2020 年 11 月 17 日
I need to find out how to make this if statment to accept the imput as capital or lower case c.
Could someone please help me out with it ?
x = input('Answer is c or C','s');
if x ~= lower('C') ,or upper('c')
disp('incorrect')
elseif x == lower('C') ,or upper('c')
disp('correct')
end

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 17 日
Apply lower() on the input x
x = input('Answer is c or C','s');
if lower(x) ~= 'c'
disp('incorrect')
elseif lower(x) == 'c'
disp('correct')
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by