Filter values in an array based on some condition

Given two arrays A and B. A contains some data belonging to 10 different class. B(i,1) gives the index of class stored in A(:,:,i). How to filter values given in A based on the classes given in B.
size(A) = 28, 28, 60000
size(B) = 60000,1
B(i, 1) belongs to 1 to 10.

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 7 日
編集済み: Ameer Hamza 2020 年 11 月 7 日

0 投票

Suppose you want to seperate values belonging to class 1 in B.
A; % 28x28x60000
B; % 60000x1
idx = B==1;
A_1s = A(:,:,idx)
To seperate all labels
A_seperated = cell(1, 10);
for i = 1:numel(A_seperated)
A_seperated{i} = A(:,:,B==i);
end
It will output a cell array.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

タグ

質問済み:

2020 年 11 月 7 日

編集済み:

2020 年 11 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by