Weird issues of Large matrix calculation & reshape function..
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to divide some numbers to large matrix A (2x300000) and then, I also want to reshape calculated matrix into (3000x100).
so I made some example code like this, but I found some bizarre issue....
I think that adding reshape functions into for loop increase the number of calculations, but when I added these functions after divide section, calculation time decreases.
Is there anyone who knows about this weird issue?
A=[1:1:300000;1:1:300000];
b=1:1:300000;
tic;
for mm=1:50
C1=A(1,:)./b;
C2=A(2,:)./b;
ximg2 = reshape(C1, 3000, 100);
yimg2 = reshape(C2, 3000, 100);
end
toc
tic;
for mm=1:50
C1=A(1,:)./b;
C2=A(2,:)./b;
end
toc
0 Kommentare
Antworten (1)
Walter Roberson
am 30 Dez. 2016
My timing tests show that the first block of code is about 3.8% slower on average, but that the random variation (due to my system doing other things at the same time) was enough that sometimes the second block measured as slower (about 10% of the time.)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Math Operations 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!