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

조회 수: 11 (최근 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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by