Weird issues of Large matrix calculation & reshape function..

조회 수: 13 (최근 30일)
chang hyun kim
chang hyun kim 2016년 12월 30일
답변: Walter Roberson 2016년 12월 30일
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

답변 (1개)

Walter Roberson
Walter Roberson 2016년 12월 30일
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.)

카테고리

Help CenterFile Exchange에서 Math Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by