Sum of a series containing table column data
조회 수: 3 (최근 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
2021년 7월 4일
It makes more sense if you post your solution here first, then we can help you to improve it.
채택된 답변
추가 답변 (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));
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!