Sum of Series - Help!

2 ビュー (過去 30 日間)
Carlen
Carlen 2014 年 10 月 23 日
回答済み: Carlen 2014 年 10 月 23 日
I have a problem where I am simply trying to calculate the series of f*cos((2*pi*t)/0.63) where
t (time) varies from [0.05:0.05:0.60] and f has different values at each of these times. Here is the vector I made for f: f=[14 24 30 36 29 21 38 5 -13 -35.5 -29 0].
For instance...14 would correspond to time 0.05.
So I need it to calculate each of these values at each time and add them up.
Thanks.

採用された回答

Guillaume
Guillaume 2014 年 10 月 23 日
No need for a loop, just use matrix elementwise multiplication:
f = [14 24 30 36 29 21 38 5 -13 -35.5 -29 0];
t = 0.05 : 0.05 : 0.6;
result = f .* cos(2*pi*t) / 0.63;
sum(result)

その他の回答 (1 件)

Carlen
Carlen 2014 年 10 月 23 日
Thanks! I was close!

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by