フィルターのクリア

indexing of discrepancy between matrices

1 回表示 (過去 30 日間)
Dylan den Hartog
Dylan den Hartog 2021 年 7 月 12 日
コメント済み: Matt J 2021 年 7 月 12 日
I want to find the discrepancy of scores.
Lets say there are three scores:
S1 = [0 1 0 2 4 3 1]
S2 = [1 1 0 4 4 3 0]
S3 = [0 2 0 4 4 1 1]
I want to find the indices of the columns where there are 1 or 2 zeros (the first and seventh column in the example). So the logical array should I want to get should be:
logical1 = [1 0 0 0 0 0 1]
idx1 = [1 7]
Also I want to find the indices of the columns where there is a difference of 2 or more between any two scores (the fourth and sixth column in the example). So the logical array should I want to get should be:
logical2 = [0 0 0 1 0 1 0]
idx2 = [4 6]
Can anyone help me out?

回答 (1 件)

Matt J
Matt J 2021 年 7 月 12 日
編集済み: Matt J 2021 年 7 月 12 日
S1 = [0 1 0 2 4 3 1] ;
S2 = [1 1 0 4 4 3 0];
S3 = [0 2 0 4 4 1 1] ;
Q=sum(~[S1;S2;S3]);
logical2=Q==1 | Q==2
logical2 = 1×7 logical array
1 0 0 0 0 0 1
Q=find(abs(S1-S2)>=2 | abs(S2-S3)>=2 | abs(S1-S3)>=2)
Q = 1×2
4 6
  2 件のコメント
Dylan den Hartog
Dylan den Hartog 2021 年 7 月 12 日
Amazing! Thank you very much.
Matt J
Matt J 2021 年 7 月 12 日
You're welcome, but please Accept-click the answer, since it seems to be what you were looking for.

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

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by