Getting parity

num = 100; source = randint(num,2); it is a 2x100
i should first row elements and j should be 2nd row elemntshow can i do it
parity = mod(source(i)+ source(j),2);

回答 (2 件)

Paulo Silva
Paulo Silva 2011 年 7 月 30 日

0 投票

code from your other question, fixed by me:
num = 100; source = randint(num,2);
r1 =source(1,:); r2 =source(2,:); parity = mod(r1+r2,2);
hope it's all correct

2 件のコメント

mahaveer hanuman
mahaveer hanuman 2011 年 7 月 30 日
i want to run for all 100 bits
Paulo Silva
Paulo Silva 2011 年 7 月 30 日
num = 100; source = randint(num,2);
parity = mod(source(:,1)+source(:,2),2)

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

Walter Roberson
Walter Roberson 2011 年 7 月 30 日

0 投票

num = 100; source = randint(num,2);
parity = xor(source(:,1), source(:,2));

1 件のコメント

mahaveer hanuman
mahaveer hanuman 2011 年 7 月 31 日
thanks for your help

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

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

タグ

質問済み:

2011 年 7 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by