Loop plus diff function with non-integers: Feasible?
조회 수: 2 (최근 30일)
이전 댓글 표시
hi all,
I am not sure if this is easy or not but I am struggling with the following:
Say that I have a vector Xt (10,000*1) of daily stock returns. I built this partition function formula:
for j=1:125;
E=Xt(1:j:end);
EE=diff(E(2:end));
EEE=diff(E(1:end-1));
Sq(j)=sum(abs(EE-EEE).^3);
end;
where j=1:125 is the various intervals that I wish to calculate the difference EE-EEE from the vector Xt. Now, what is the most efficient way for me to calculate the EE-EEE using non integer numbers?
If I construct a new vector as follow:
expo=0:1000;
A=1.1*ones(size(expo));
ddt=A.^expo;
in ddt there are numbers in which I would like to implement rather than 1:125.
(ddt vector looks like [1 1.1 1.21 1.331 1.4641 1.61051 1.771561 1.9487 2.14358]
What's the best way for to achieve this? In my orignal formula, I generate a Sq vector of size 1X125 for integer intervals but I want more numbers therefore I must turn to non-integer numbers.
Thank you very much for the help!
댓글 수: 0
채택된 답변
Oleg Komarov
2012년 5월 31일
If I understood correctly, you want to partition non non integer ontervals. Say you want to select Xt every 1.331 step.
Since you have values only at Xt(1), Xt(2) etc... and not on Xt(1.331), Xt(2.662) etc but you still want to get those number then you can interpolate.
댓글 수: 2
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!