フィルターのクリア

Error using bitget and bitset in array

2 ビュー (過去 30 日間)
kash
kash 2012 年 11 月 23 日
I havr a code below,it returns error using array
C=[1081;1056];
for i=1:11
if (bitget(C(i),5)==1)
P=bitset(C(i),5,0);
P=dec2bin(P);
end
end
please provide assistance

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 23 日
編集済み: Azzi Abdelmalek 2012 年 11 月 23 日
The size of C is 2 and you re using for i=1:11
Index exceeds matrix dimensions, because C(3) does'nt exist
C=[1081;1056];
for i=1:2
if (bitget(C(i),5)==1)
P=bitset(C(i),5,0);
P=dec2bin(P);
end
end
% Don't use i & j as an indexes (they are used for complex number)
  2 件のコメント
kash
kash 2012 年 11 月 23 日
Azzi if i type P ,i get only one value
P =
10000101001 where as i should get 2 values
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 23 日
編集済み: Azzi Abdelmalek 2012 年 11 月 23 日
clear
C=[1081;1056];
for ii=1:2
if (bitget(C(ii),5)==1)
P1=bitset(C(ii),5,0);
P{ii}=dec2bin(P1)
end
end
The number of values depends on your test

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by