Info
この質問は閉じられています。 編集または回答するには再度開いてください。
operation array in cell
1 回表示 (過去 30 日間)
古いコメントを表示
i have 2 matrix A and B and cell Z with 13*13 blocks. each blocks have 8*8 pixel.
A=rand(13,13,8,8);
B=rand(13,13,8,8);
i want to process value A and B with each blocks in cell Z.
XY = (Z*A)+B
example, value at A if you see at workspace, start with val(:,:,1,1), there's will be 169 value of A. each value will be process with every blocks of Z to get XY. same with matrix B. total blocks of Z is same with total value of A and B in val {:,:,1,1}.
specificly,
XY{1,1}=Z{1,1}.*A{1,1,1,1} + B{1,1,1,1},
XY{1,2}=Z{1,2}.*A{1,2,1,1}+B{1,2,1,1} until the whole blocks of Z.
回答 (1 件)
Andrei Bobrov
2013 年 3 月 5 日
編集済み: Andrei Bobrov
2013 年 3 月 5 日
A1 = permute(A,[3 4 1 2]);
B1 = permute(B,[3 4 1 2]);
XY = Z;
for ii = 1:size(Z,1)
for jj = 1:size(Z,2)
XY{ii,jj} = Z{ii,jj}.*A1(:,:,ii,jj) + B1(:,:,ii,jj);
end
end
ADD variant
Zn = cat(3,Z{:});
s = size(A);
A1 = reshape(permute(A,[3 4 1 2]),s(3),s(4),[]);
B1 = reshape(permute(B,[3 4 1 2]),size(A1));
XY = reshape(num2cell(Zn.*A1+B1,[1 2]),size(Z));
7 件のコメント
Jan
2013 年 3 月 6 日
@Internazionale: It would help, if you post the code you are using and a complete copy of the error message. Andrei hast posted two different solutions, and you could potentially have modified one of them, e.g. by a typo. We cannot reliably guess the cause of the error on your computer, so it is your job to explain the circumstances.
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!