Undefined function error
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I am trying to create one cipher text program where if input text is alphabet then program will pick cipher text from character input/output array, if input text is digit/special char then program will pick cipher text from other input/oupt array
example-
Input Text= 'n1'
For n cipher text should be 'k' where as for 1 cipher text should be 6 but my program fails with error as
??? Undefined function or variable "Q".
Error in ==> Untitled2 at 41
Code-
Code Removed...
Pls provide me directions to get rid of this error
Thanks in Advance
댓글 수: 0
채택된 답변
bym
2011년 11월 13일
change these lines:
if txtisalpha==1
elseif txtisalpha==0
to
if txtisalpha(j)==1 % txtisalpha is a vector
else % don't need 'elseif'
추가 답변 (1개)
Walter Roberson
2011년 11월 13일
You have an if / elseif / end structure, but you do not assign anything if neither the if nor the elseif conditions are true.
Your if and elseif conditions do not cover the entire set of possibilities: the output from ismember() might be something that is not 0 and is not 1. For example, the output from ismember() applied to the character vector 'n1' could be the vector [1 0] .
When you have a vector (or array) being evaluated in an "if" condition, the situation is well defined: MATLAB considers the "if" to be satisfied exactly in the case that all the values of the vector (or array) are non-zero (true).
[1 0] == 1 yields [true false] and since that is not all true, the "if" is not satisfied. And you then elseif [1 0] == 0, which yields [false true] and since that is not all true, the elseif is not satisfied either. But you don't have any "else" on the elseif to handle the case where neither the if nor the elseif were satisfied.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!