I need to store each block's result in cell, i am using blockproc.How to do it in matlab?

uxor=blockproc(kk,[8 8],@feature_xor, 'padpartialblocks', true);
function:
function uxor = feature_xor(block_struct)
block = block_struct.data;
ur = unique(block(1:end-1) | block(2:end), 'rows');
uxor = mod(sum(ur,1),2);
end
in want to store "uxor" result of each block in separate cell

 Accepted Answer

[rows,cols] = size(uxor);
uxor_cell = mat2cell(uxor, ones(1,rows), 8 * ones(1, cols/8));

6 Comments

could u please explain me this 2nd line of code sir
uxor_cell = mat2cell(uxor, ones(1,rows), 8 * ones(1, cols/8));
Read about mat2cell()
The ones(1,rows) is [1 1 1 1 ... 1] for nrows entries, and in that position in the mat2cell() call signifies that the matrix is to be broken up into cells that are one row each.
ones(1,cols/8) is [1 1 1 ... 1] for cols/8 entries. Multiply that by 8 to get [8 8 8 .... 8] for cols/8 entries, which is going to add up to cols. In this position in the mat2cell() call, it indicates that the matrix is to be broken up into cells that are 8 columns wide.
I am going by memory here from when I wrote feature_xor for you that the result of the computation is a vector of 1 row by 8 columns, so getting the results into individual cells would be the same as breaking up the uxor matrix into cells of 1 row by 8 columns.
ok sir, if i need to store each blocks result(uxor of each block) in array means,what is the matlab code?reply me sir
The mat2cell() will create the cell of results you originally asked for. The blockproc() you already have stores all the results in one numeric array together.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!