필터 지우기
필터 지우기

A is a matrix of size 32*32.I want to subtract elements of each 4*4 block of A from their respective 4*4 means

조회 수: 2 (최근 30일)
A is a matrix of size 32*32. out = blockproc(A,[4 4],@(x)mean(x.data(:)));
Using the above code, I am able to reduce A to 8*8 which is obtained by averaging each 4*4 blocks of A. Now, I want to subtract elements of each 4*4 block of A from their respective 4*4 means. Thanks !

채택된 답변

Matt J
Matt J 2020년 2월 12일
편집: Matt J 2020년 2월 12일
out = blockproc(A,[4 4],@(x)mean(x.data(:)));
result = A - repelem( out , 4,4);
  댓글 수: 4
bidlee devi
bidlee devi 2020년 2월 13일
After running the code
result1 = A - repelem( out , 4,4);
It says
"Undefined function 'repelem' for input arguments of type 'double'."

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Fangjun Jiang
Fangjun Jiang 2020년 2월 12일
편집: Fangjun Jiang 2020년 2월 12일
A=rand(32);
out = blockproc(A,[4 4],@(x)mean(x.data(:)));
temp=repmat({ones(4,1)},8,1);
temp=blkdiag(temp{:});
Result=A-temp*out*temp'
%% or run below to see the effect
temp*magic(8)*temp'

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by