フィルターのクリア

Is there anything wrong to my code?

4 ビュー (過去 30 日間)
jelly
jelly 2012 年 10 月 7 日
if (((N(end)=='A'||N(end)=='B'||N(end)=='C'||N(end)=='D'||N(end)=='E'||N(end)=='F') && (b1>=10))|| str2num(N(end))>=b1)
end
my matlab says that:
Operands to the || and && operators must be convertible to logical scalar values.
Error in sample (line 22)
if (((N(end)=='A'||N(end)=='B'||N(end)=='C'||N(end)=='D'||N(end)=='E'||N(end)=='F') && (b1>=10))||
str2num(N(end))>=b1)
fprintf(2, '|| ERROR! || The digit/s of the number you desire to convert SHOULD NOT EXCEED the value of initial base\n')
return;
whats wrong here? my input is N=9A then my b1=9(str type) then my b2=10.

採用された回答

Matt Fig
Matt Fig 2012 年 10 月 7 日
編集済み: Matt Fig 2012 年 10 月 7 日
I don't think you have told the whole story:
>> N = '9A';
>> b1='9';
>> (((N(end)=='A' || ...
N(end)=='B' || ...
N(end)=='C' || ...
N(end)=='D' || ...
N(end)=='E' || ...
N(end)=='F') && ...
(b1>=10))|| ...
str2num(N(end))>=b1)
ans =
1
By the way, why do you say b1 is a string, then check to see if it is greater than 10? Either way, calling STR2NUM on N(end) will result in an empty array because 'A' can't convert to a number...
Also, try this:
~isempty(strfind('ABCDEF',N(end)))
  1 件のコメント
jelly
jelly 2012 年 10 月 7 日
thankyou so much bor! *brofist*

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

その他の回答 (1 件)

jelly
jelly 2012 年 10 月 7 日
編集済み: jelly 2012 年 10 月 7 日
haha i think i know whats wrong in my code, maybe because str2num(N(end))>b1 would not be valid operand. haha but how can I fix this?
  1 件のコメント
Walter Roberson
Walter Roberson 2012 年 10 月 7 日
Please show your current code, and the error message you are currently experiencing, and show
class(b1)
size(b1)

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

カテゴリ

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