Comparison between two vectors

4 ビュー (過去 30 日間)
Trevor Badji
Trevor Badji 2017 年 12 月 11 日
コメント済み: Rena Berman 2017 年 12 月 26 日
[1;0;1;1;0;1;1;0;1;0]
[0 1 0 0 0 1 1 0 1 1]
I want to compare these two vectors. I want MATLAB to write as a result of it; which means error number of ith element. For example, first elements are different the error is 1, seconds are different error still 1, until 5th elements error is still 1 at the fifth there 4 errors out of 5 therefore 4/5. and it goes on.
[1 1 1 1 0.8 0.66 0.57 0.5 0.44 0.5]
  2 件のコメント
KL
KL 2017 年 12 月 11 日
You have to rephrase your question with a better example.
Rena Berman
Rena Berman 2017 年 12 月 26 日
(Answers Dev) Restored edit

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

採用された回答

Image Analyst
Image Analyst 2017 年 12 月 11 日
You asked
" [1;0;1;1;0;1;1;0;1;0] [0 1 0 0 0 1 1 0 1 1]
I want to compare these two vectors. I want MATLAB to write as a result of it; which means error number of ith element. For example, first elements are different the error is 1, seconds are different error still 1, until 5th elements error is still 1 at the fifth there 4 errors out of 5 therefore 4/5. and it goes on.
[1 1 1 1 0.8 0.66 0.57 0.5 0.44 0.5]
"
(posted in case you delete your question like you've done before).
Here is how I'd do it:
v1 = [1;0;1;1;0;1;1;0;1;0]
v2 = [0 1 0 0 0 1 1 0 1 1]
c = v1' ~= v2
output = cumsum(c) ./ [1:length(c)]
  3 件のコメント
Image Analyst
Image Analyst 2017 年 12 月 11 日
Sorry, I don't know that language. I have no idea what "* _ Eyvallah KRAAAAL_*" means.
Trevor Badji
Trevor Badji 2017 年 12 月 11 日
It means thank you very much king :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by