필터 지우기
필터 지우기

Help with "matrix dimensions must agree".

조회 수: 2 (최근 30일)
Kyle Reagan
Kyle Reagan 2016년 12월 4일
댓글: Star Strider 2016년 12월 4일
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
Kyle Reagan
Kyle Reagan 2016년 12월 4일
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일
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개)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by