Summation formula of two variables using vectorization

9 ビュー (過去 30 日間)
Dakota Grey
Dakota Grey 2016 年 3 月 2 日
回答済み: Sebastian Castro 2016 年 3 月 3 日
I am trying to implement the following formula for research purposes:
Where M = 100, so m = -100:100 and t is also a vector. and fm = f0 + m (where f0 is a defined constant)
I am able to implement this using a for loop; however, I would like to use vectorization for speed and usability. I believe there should be a way to implement this using vectors alone and no loops, but I have been having trouble doing so due to the presence of two variables in the summation. I also am not able to use the symbolic toolbox due to the application. Any advice would be appreciated.
  2 件のコメント
John D'Errico
John D'Errico 2016 年 3 月 2 日
What is T?
Dakota Grey
Dakota Grey 2016 年 3 月 3 日
T is the period. It is also a constant.

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

回答 (1 件)

Sebastian Castro
Sebastian Castro 2016 年 3 月 3 日
You should be able to do:
sum(G(fm).*cos(2*pi*fm*t - pi*fm*T))
... assuming that G(x) is a function whose output is always the same size as its input.
- Sebastian

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by