Concatenate large matrices a bottleneck in function
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I have a function that concatenates two matrices, size of 100000 X 90 for an outcome of 100000 X 180.
This is a significant bottleneck as the function has to repeat many times.
Pre-allocating the outcome does not seem to make any difference, and using cat() or [] also seems to make no difference.
Does anyone have suggestions on how to speed this up?
Thank you.
2 件のコメント
Sylvain
2020 年 11 月 4 日
can you post your code?
are you trying to do this ?
A=ones(100000,90);
B=2*ones(100000,90);
C = [A,B];
回答 (1 件)
Subhadeep Koley
2020 年 11 月 4 日
A = ones(100000,90);
B = 2*ones(100000,90);
result = horzcat(A, B);
1 件のコメント
Walter Roberson
2020 年 11 月 4 日
The timing tests I tried show horzcat(A,B) and [A,B] and cat(2,A,B) to be indistinguishable in timing -- the differences were below random variation
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!