# Sum of a series containing table column data

3 ビュー (過去 30 日間)
Leo Tu 2021 年 7 月 4 日

I have a table, T, with one column of data of length 12054. I need to then make the following sum
SUM_[k=0 to t-1] 0.5^abs(k-5)*T(t-k)
lambda(t) = 1 + ---------------------------------------------------------------
SUM_[k=0 to t-1] 0.5^abs(k-5)
I have tried using symsum and defining the numerator and denominator seperately but I cannot seem to get it right. If anyone could help me with this it would be much appreciated.
Edit: Below is my attempt
syms k x;
% S1(t) is my attempt at defining the numerator
S1(t) = symsum(0.5^(abs(k-5)*T(t-k)),k,0,t-1);
Unrecognized function or variable 't'.
% Next is my attempt at defining the denominator
for t=0:12054
S2(t) = symsum(0.5^(abs(k-5)),k,0,t-1);
end
Array indices must be positive integers or logical values.
Error in sym/privsubsasgn (line 1151)
L_tilde2 =
builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
Error in sym/subsasgn (line 972)
C = privsubsasgn(L,R,inds{:});
Edit 2: Second attempt at defining the numerator
syms k x;
>> for t=1:12054
S1(t) = symsum(0.5^(abs(k-5)*T(t-k)),k,0,t-1);
end
Error using sym/subsindex (line 864)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments
must be symbolic variables, and function body must be sym expression.
##### 2 件のコメント表示非表示 1 件の古いコメント
Leo Tu 2021 年 7 月 4 日
Sorry @Yongjian Feng, I have edited the post.

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

### 採用された回答

Leo Tu 2021 年 7 月 5 日
For anyone interested, I have found a solution.
V = flip(T,1)
syms k;
for t=1:12054
L(t) = 1+symsum(.5.^abs(k-5)*V(t),k,0,12054-t)./symsum(.5.^abs(k-5),k,0,12054-t);
end
lambda = double(L);
lambda = flip(lambda,2) % flipping back because we initially flipped T to get V.

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

### その他の回答 (1 件)

Sulaymon Eshkabilov 2021 年 7 月 4 日
What is the value of k? Just presuming k is taken from the number of elements in T, the calc can be done, e.g:
k=0:numel(T)-1;
L=1+sum(.5.^abs(k-5)*T(1:end-k))./sum(.5.^abs(k-5));
##### 1 件のコメント表示非表示 なし
Leo Tu 2021 年 7 月 4 日
Hi there, k is the summation index from k = 0 to k = t-1, where t is in relation to T(t) for t=1:12054.
So the result lambda(t) would be a vector (I think) of length 12054.

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

R2021a

### Community Treasure Hunt

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

Start Hunting!