Help me to optimise or vectorize the code

1 回表示 (過去 30 日間)
SammyNHarry
SammyNHarry 2014 年 1 月 28 日
編集済み: Patrik Ek 2014 年 1 月 28 日
Hi
Here is a snippet of the code below. I wonder if there is anything else that the code can be optimised or vectorized especially between line 2 to line 5?
1 outSignal = y11.*-d11-y12.*d12+x11.*n11+ x12.*n12;
2 y12 = y11(:);
3 y11 = outSignal(:);
4 x12 = x11(:);
5 x11 = inSignal(:);
6 output = outSignal(:);
I would be greatly appreicated if you can offer me suggestion.
  1 件のコメント
Patrik Ek
Patrik Ek 2014 年 1 月 28 日
編集済み: Patrik Ek 2014 年 1 月 28 日
May I ask what you are doing here? The operator that you use is an inbuilt operator and I doubt that there are any faster way to do the same operation. That would only be a marginal difference anyway.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 1 月 28 日
The (:) operator is one of the fastest operations in MATLAB, as all it needs to do is create a new header and increment the usage count (for copy-on-write purposes): in particular, the data block pointer is copied without needing to copy or duplicate the data itself. All that is being changed is the header indicating how the data is organized, not the data itself.

カテゴリ

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