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

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개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

2020년 11월 17일

답변:

2020년 11월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by