フィルターのクリア

Sigma notation - two variables. 'for' loop or symsum?

2 ビュー (過去 30 日間)
Nate
Nate 2014 年 10 月 20 日
コメント済み: Roger Stafford 2014 年 10 月 22 日
Hello
I am trying to compute a sigma summation of a simple single column vector x, where:
N = length(x)
k = 0:N/4
i = 1:N-k
I need to solve for Axx(k):
I have tried to solve this using 'for' loops and symsum function, without success. Help is hugely appreciated, thanks.

採用された回答

Star Strider
Star Strider 2014 年 10 月 20 日
This runs:
N = length(x);
for k = 0:N/4
Axx(k+1) = 0;
for i = 1:N-k
Axx(k+1) = Axx(k+1) + x(i)*x(i+k);
end
end
I’ll let you determine if it gives the answers you expect.
  2 件のコメント
Nate
Nate 2014 年 10 月 22 日
編集済み: Nate 2014 年 10 月 22 日
Yes - it works perfectly, thanks.
Also - this seems to work as well:
N = length(x);
for k = 0:(N/4);
Axx(k+1) = sum((x(1:N-k,2)).*(x(1+k:N,2)));
end
Star Strider
Star Strider 2014 年 10 月 22 日
My pleasure!

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

その他の回答 (1 件)

Roger Stafford
Roger Stafford 2014 年 10 月 21 日
Axx = x.'*hankel(x,zeros(1,N/4+1));
  2 件のコメント
Nate
Nate 2014 年 10 月 22 日
Thanks for this. I get an error when used with my 'x' vector.
Error using zeros Size inputs must be integers.
I found something that seems to work (see my comment below).
Thanks
Roger Stafford
Roger Stafford 2014 年 10 月 22 日
That's probably because your value N is not a multiple of 4. Do this:
round(N/4)+1
instead.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by