Finding last observation below threshold
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
I have a dataset of 535 observations of time, price and volume (dataTrades matrix in the code underneath) that i would like to cut down to 78 based on a time variable (column 1 in dataTrades matrix).
The time variable is in seconds and i need to divide my data into 5 min intervals.
trades=dataTrades(:,1);
firstObs=dataTrades(1,1);
intervals=zeros(78,1);
closest=zeros(78,1);
intervals(1)=firstObs;
for l=2:78
intervals(l)=intervals(l-1)+300;
end
I made this code to generate the 78 5-min intervals. Now what i need to do is to select the observations in dataTrades that has the time closest to (lower or equal to) the time intervals in the intervals vector and pair it with that row in the intervals vector.
For example the first time is 34675 (seconds from 0 am UTC time), so the next interval 5 min later has a time of 34675+300=34975 (300 = 5 min).
In the dataTrades time column the latest time under 34975 would be row 16 with a time of 34923.
So in the interval vector (or now matrix) i would like to copy the data from dataTrades row 16 (price and volume) to the interval matrix row 2.
And so on for the other 76 intervals.
Hope it makes sense. It's a lot of text but i don't think it's super advanced - i just don't know how to do it. Thanks!
0 件のコメント
回答 (0 件)
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!