Undefined function or variable error
조회 수: 1 (최근 30일)
이전 댓글 표시
option=input('Do you want to continue?(Y/N)','s');
while option == Y
%here comes body of loop
option=input('Do you want to continue?(Y/N)','s');
end
it says undefined function or variable input when I enter Y
댓글 수: 0
채택된 답변
Jan
2018년 12월 3일
편집: Jan
2018년 12월 3일
Replace while option == Y by
while strcmpi(option, 'y')
In your code Y is a function call, not the character, because the quotes are missing. Using strcmpi accepts lower and upper case characters and compares the string in total, not elementwise as teh == operator. See:
c = 'yy'
c == 'y' % This compares both characters and replies [true, true]
strcmp(c, 'y') % This is a scalar as wanted
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!