Loop plus diff function with non-integers: Feasible?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Oleg Komarov
il 31 Mag 2012
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 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!