Undefined function error

1 次查看(过去 30 天)
Nil
Nil 2011-11-13
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

采纳的回答

bym
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
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.
  1 个评论
Nil
Nil 2011-11-14
Thanks Walter Roberson for much detailed explanation, Helped me to resolve issue !!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Encryption / Cryptography 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by