Matrix moving mean with overflow average
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Albert Zurita
am 13 Nov. 2022
Kommentiert: Albert Zurita
am 15 Nov. 2022
I am wondering if there is a (simply) way when using movmean for controlling row overflow and for specifying a rectangular window instead of a square window. The idea would be to keep averaging the patch corresponding to each number in red until the end of row is found, and simply jump to the next row. Thanks!
0 Kommentare
Akzeptierte Antwort
Matt J
am 13 Nov. 2022
Bearbeitet: Matt J
am 13 Nov. 2022
Here's one way. I assumed here you want the same wrap-around to occur in the lower-right corner of the matrix as well.
A=reshape(1:24,[],4)'
B=[A,circshift(A(:,1:2),-1) ]
slidingMeans=conv2(B,ones(3)/9,'valid')
5 Kommentare
Matt J
am 15 Nov. 2022
win = [3 5]; % rows, cols
A=reshape(1:24,[],4)'
B=[A,circshift(A(:,1:win(2)-1),-1)];
B(end,end-win(2)+2:end)=nan
slidingMeans=conv2(B,ones(win)/prod(win),'valid' )
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!