Undefined function error
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
bym
le 13 Nov 2011
change these lines:
if txtisalpha==1
elseif txtisalpha==0
to
if txtisalpha(j)==1 % txtisalpha is a vector
else % don't need 'elseif'
Plus de réponses (1)
Walter Roberson
le 13 Nov 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.
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!