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 件のコメント
Nil
Nil 2011 年 11 月 14 日
Thanks Much..Got issue resolved :)

サインインしてコメントする。

その他の回答 (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 Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by