Optimizing a Sliding Window for Matrix Re-Assignment

1 回表示 (過去 30 日間)
Al Capwn
Al Capwn 2015 年 10 月 29 日
コメント済み: Al Capwn 2015 年 10 月 30 日
I have a matrix, A, which is a massive NxM matrix where N is several millions and M is relatively small. and I would like to do an operation (xcorr() or std(), for example) on a window of this matrix, A(i:i+x,:), for i=1:N. However, using "for" loops ends up taking a lot of time since Matlab and "for" loops get along like me and my "ex" wife.
I'm trying to optimize it by creating a new matrix, B composed of the windows of A. For example, if
A=[1 2 3 4 5 6 8 9 10],
and the window size is x=3,
B= [1 2 3
2 3 4
3 4 5
...
8 9 10]
Is there any way to optimize this using only vector/matrix operations in order to speed up processing?
  1 件のコメント
Eng. Fredius Magige
Eng. Fredius Magige 2015 年 10 月 29 日
You have post 3 times the same QUESTION, please do just once; any amendment might use comment to verify etc.
Put clear you task; note that and mostly vectorization handle it/assignment quickly (in fraction of minutes) Thanks

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

採用された回答

Thorsten
Thorsten 2015 年 10 月 29 日
編集済み: Thorsten 2015 年 10 月 29 日
If you have the image processing toolbox, you can use:
stdA3 = colfilt(A, [3 1], 'sliding', @std);
  1 件のコメント
Al Capwn
Al Capwn 2015 年 10 月 30 日
Wowza, it's about 10x faster, thanks!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by