how to reduce the size of a matrix?
Ältere Kommentare anzeigen
Suppose I have 4 by 4 matrix or of any size and I want to make it a 2by2 matrix by taking the average of the sub matrixes.
Akzeptierte Antwort
Weitere Antworten (1)
n = 4;
A = rand(n,n);
A_reduced = zeros(n/2,n/2);
for i=1:n/2
for j=1:n/2
Ahelp = A(2*(i-1)+1:2*i,2*(j-1)+1:2*j);
A_reduced(i,j) = mean(Ahelp(:));
end
end
A
A_reduced
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!