Nested For Loop for 2D Matrix
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to create a nested for loop that essentially goes through a 2D matrix of 600x1000 dimensions, such that in every loop in both of the dimensions it picks out exactly 51x51 part of the 2D matrix in either of the dimensions and multiplies it to another 51x51 separate matrix.
0 Kommentare
Akzeptierte Antwort
Matt J
am 11 Nov. 2019
Bearbeitet: Matt J
am 11 Nov. 2019
So then you want to extract random 51x51 submatrices? If so, then,
I=sort(randperm(600,51));
J=sort(randperm(1000,51));
submatrix= matrix(I,J);
2 Kommentare
Matt J
am 11 Nov. 2019
Is it element-wise multiplication, or another kind? And what is to be done with each of the 51x51 multiplication results? In double floating point, this will require 10 GB of storage if they are kept simultaneously in memory,
>> (600-51)*(1000-51)*51^2*8/2^30
ans =
10.0965
Weitere Antworten (1)
Matt J
am 11 Nov. 2019
I vaguely wonder whether you are just re-inventing convolution
result = conv2(Matrix,staticMatrix,'valid');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!