How to count matrix values in positions specified by other matrix?

1 回表示 (過去 30 日間)
Rene Sebena
Rene Sebena 2016 年 6 月 1 日
コメント済み: Rene Sebena 2016 年 6 月 1 日
Hi there, I am trying to solve this task, I have matrix with Experimental Conditions eg:
A =
9 10 12
11 11 15
13 14 11
and corresponding Accuracy matrix with logical values 1 (for the correct responses) and 0 (for incorrect responses), eg:
B =
0 0 1
1 0 0
1 1 1
What I need to do, is to count up the correct trials eg. for experimental conditions 11 and 12 (together), so in this case the result would be 3.
Thank you in advance.
Rene

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 6 月 1 日
編集済み: Azzi Abdelmalek 2016 年 6 月 1 日
out=nnz(ismember(A,[11 12]).*B)
or
out=nnz(ismember(A(logical(B)),[11 12]))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by