Undefined function error

1 visualización (últimos 30 días)
Nil
Nil el 13 de Nov. de 2011
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

Respuesta aceptada

bym
bym el 13 de Nov. de 2011
change these lines:
if txtisalpha==1
elseif txtisalpha==0
to
if txtisalpha(j)==1 % txtisalpha is a vector
else % don't need 'elseif'
  1 comentario
Nil
Nil el 14 de Nov. de 2011
Thanks Much..Got issue resolved :)

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 13 de Nov. de 2011
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 comentario
Nil
Nil el 14 de Nov. de 2011
Thanks Walter Roberson for much detailed explanation, Helped me to resolve issue !!

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by