フィルターのクリア

How can I logically index 3 conditions in a loop

2 ビュー (過去 30 日間)
Hatice Sahin
Hatice Sahin 2019 年 5 月 15 日
コメント済み: Hatice Sahin 2019 年 5 月 16 日
I have a simplified version of my data as;
d=[3 1
4 1
3 4
4 4
2 1
3 1
2 3
1 3
1 4];
first coloumn are the responses(1,2,3 or 4). second column are the error types(1,2,3 or 4).
I want to create a loop that gives me a logical matrix for indexing to use later in my analysis.
index_mat=if the first column is 3 or 4 and the second column is 1
index_mat2= if the first coloumn is 3 or 4 and the second column is 4
so I expect;
index_mat= 1 0 0 0 1 0 0 0
index_mat2= 0 1 1 0 0 0 0 0
Thank you

採用された回答

Fangjun Jiang
Fangjun Jiang 2019 年 5 月 15 日
and(or(d(:,1)==3, d(:,1)==4),d(:,2)==1)
  1 件のコメント
Hatice Sahin
Hatice Sahin 2019 年 5 月 16 日
It worked on my data. Thank you :)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by