Sum of a series containing table column data

5 次查看(过去 30 天)
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 个评论
Yongjian Feng
Yongjian Feng 2021-7-4
It makes more sense if you post your solution here first, then we can help you to improve it.

请先登录,再进行评论。

采纳的回答

Leo Tu
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
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
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by