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 Center および File ExchangeMath Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by