gathering two cells in confusion matrix
2 ビュー (過去 30 日間)
古いコメントを表示
If I have a 4*4 confusion matrix array [1 1 3 2; 1 0 2 1 ; 7 4 3 1; 5 6 3 7]. how can I combining both 2*2 regions are next to each other in order to constract a new array of 2*2 [3 8; 22 14]
0 件のコメント
採用された回答
Fangjun Jiang
2020 年 4 月 2 日
編集済み: Fangjun Jiang
2020 年 4 月 2 日
If you have the Image Processing toolbox,
a=[1 1 3 2; 1 0 2 1 ; 7 4 3 1; 5 6 3 7];
fun = @(block_struct) sum(block_struct.data(:));
blockproc(a,[2 2],fun)
ans =
3 8
22 14
if Not,
a=rand(6,9);
RowBlock=2;
m=size(a,1)/RowBlock; % make sure m is an integer
ColBlock=3;
n=size(a,2)/ColBlock; % make sure n is an integer
b=mat2cell(a,repmat(RowBlock,1,m),repmat(ColBlock,1,n));
c=cellfun(@(x) sum(x(:)), b)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!