In my code I have an input that says answer = input('Please type "yes" or no".','s'); if answer == 'yes' blah blah else disp('Error, please make sure a file is uploaded.') end
For some reason when I enter "no", there is a problem where it says "Error. Matrix dimensions don't agree." But when i enter "n" it gives me my custom error statement for the else condition.

댓글 수: 1

if true
% answer = input('Has a file been uploaded? Answer "yes" or "no" in the command window. \n','s');
if answer == 'yes'
figure
histogram(file)
else
disp('Error. Something went wrong. Please exit program and try again. \n')
end
end

댓글을 달려면 로그인하십시오.

 채택된 답변

Star Strider
Star Strider 2016년 12월 4일

0 개 추천

Change the if condition to:
if strcmp(answer, 'yes')

댓글 수: 2

Kyle Reagan
Kyle Reagan 2016년 12월 4일
Thanks, works like a charm!
Star Strider
Star Strider 2016년 12월 4일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

질문:

2016년 12월 4일

댓글:

2016년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by