フィルターのクリア

Out of these two methods, which one is computationally intensive and why?

2 ビュー (過去 30 日間)
Syed Haider
Syed Haider 2017 年 12 月 25 日
コメント済み: Walter Roberson 2017 年 12 月 26 日
I have a signal, let's say A6. It has 300 sample points. There are two different methods to estimate the magnitude of the signal. I want to know which method is computationally intensive.
The steps of the first method are as followed,
Step1: A = A6 - mean(A6);
Step2: B = A .* A;
Step3: C = cumsum(B);
Step4: D = trapz(C);
D represents the magnitude of the signal in terms of area under the curve.
The steps of the second method are as followed,
Step1: A = A6 .* A6;
Step2: B = cumsum(A);
Step3: Mean Square Error (MSE) between B and fitted straight line.
The value of the MSE represents the magnitude of the signal.
Thanks,
Irtaza
  2 件のコメント
James Tursa
James Tursa 2017 年 12 月 25 日
Why don't you code both of them up and then run the profiler?
Syed Haider
Syed Haider 2017 年 12 月 25 日
Thanks for the suggestion but I am looking for the theoretical explanation. Step4 of the first method vs. Step3 of the second method.

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

採用された回答

Walter Roberson
Walter Roberson 2017 年 12 月 25 日
trapz should have a lower constant of proportion because it is sum(C) - (C(1)+C(end)) /2 whereas mse requires sqrt(sum((C-B).^2)). Both are linear in size but one requires squaring as well as sum.
  2 件のコメント
Syed Haider
Syed Haider 2017 年 12 月 26 日
Thanks Walter for the explanation. Is there a method faster than trapz to calculate the area under the curve.
Walter Roberson
Walter Roberson 2017 年 12 月 26 日
Unless you have a formula for the curve, there would be no way to calculate the area without examining each value at least once, which is all that trapz requires.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by