フィルターのクリア

Determining the difference between two vectors

20 ビュー (過去 30 日間)
osman yurdakul
osman yurdakul 2011 年 3 月 24 日
コメント済み: Anu Shivalinga 2022 年 7 月 29 日
hello friends,
i have to find error between 2 array. i sent a data from transmitter to receiver.
data transmitted is;
td = [1 1 1 0 0 0 1 1 0 1 0 1 1 0 0];
and the data received is;
rd = [0 1 1 0 1 0 1 1 0 1 0 1 1 0 1];
and the number of error is 3 as it is seen above
but how can i find the error number by matlab code?..
Thanks for your helps.

採用された回答

Paulo Silva
Paulo Silva 2011 年 3 月 24 日
numel(find(td~=rd))

その他の回答 (3 件)

Matt Fig
Matt Fig 2011 年 3 月 24 日
Expanding on Paulo's answer, to get the logical index locations of the errors, do this:
locs = td~=rd
now to find out how many there are, I would use
errornumber = sum(locs) % Or just sum(td~=rd) if locs not needed.
If you need the linear index number of the errors, then use FIND, as Paulo shows.
  2 件のコメント
Paulo Silva
Paulo Silva 2011 年 3 月 24 日
simple code :) +1 vote
Anu Shivalinga
Anu Shivalinga 2022 年 7 月 29 日
Hello, this works perfect. Thanks. But what if sizes of 2 arrays are not equal? How to find the mismatch between those?

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


Paulo Silva
Paulo Silva 2011 年 3 月 24 日
yet another way
sum((td & rd | (~td & ~rd))==0)
even more simple
sum(~((td & rd | (~td & ~rd))))
even better
sum(xor(td,rd))

osman yurdakul
osman yurdakul 2011 年 3 月 24 日
thanks for all helps it's working properly now thanks again ...

カテゴリ

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