Quicker function than repmat to multiplay matrices with vectors?

10 ビュー (過去 30 日間)
Tim
Tim 2014 年 3 月 14 日
コメント済み: Tim 2014 年 3 月 14 日
I've recognised that in my programm the most time-consuming parts are the parts where I use repmat, most of the times when I want to multiply a large Matrix with a vector. Is there an easier way?
The main problem was to vectorize the code instead of using loops all the time, but now, since I replicate a lot of data to get matrix-operations running, the program ist not really quicker...Are there better alternatives?
E.g.: LargeMatr=[ 1 2 3; 4 5 6; 7 8 9] %in reality around 40000 x 1000 elements
Vector=[ 1 3 4]'; % One column/ In reality with 40000 elements x 1 element
Result= LargeMatr.*Vector % is not possible, so I have to do this:
Result= LargeMatr.*repmat(Vector,1,3);
Is this already the most efficient way? Or would a loop even be quicker?
Thanks a lot!

採用された回答

per isakson
per isakson 2014 年 3 月 14 日
編集済み: per isakson 2014 年 3 月 14 日
There is an example in the documentation of bsxfun that applies to your problem.
  1 件のコメント
Tim
Tim 2014 年 3 月 14 日
Thanks a lot! That really improves the performance!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by