Changing time intervals

Hi everybody.
I have a huge matrix where the first 6 entries are shown below. I want to change the NON EQUAL time intervals into EQUAL time intervals of 1 second. :
'27/01/2012 15:30:00' 'TRADE' 58.2000000000000
'27/01/2012 15:31:33' 'TRADE' 58.3749000000000
'27/01/2012 15:49:19' 'TRADE' 58.5600000000000
'27/01/2012 15:49:19' 'TRADE' 58.5400000000000
'27/01/2012 15:50:26' 'TRADE' 58.4900000000000
'27/01/2012 15:55:22' 'TRADE' 58.6054000000000

댓글 수: 2

Jan
Jan 2012년 2월 13일
Please explain any details of the wanted procedure. Which values do you expect after the "change"?
Mate 2u
Mate 2u 2012년 2월 13일
I would like it in secondly interval and the values would remain until changed. Eg, 15:30:01 would be still 58.200
15:30:02 would still be 58.2
Then at 15:31:33 price would change to 58.3749
Then all seconds after it would remain the same until 15:49.19 where there are 2 values, we choose the last value 58.54.
I hope you understand now. The second column has nothing to do with anything its just 'Trade' a string.

댓글을 달려면 로그인하십시오.

 채택된 답변

Friedrich
Friedrich 2012년 2월 14일

0 개 추천

Hi,
check the values where the price changes. Maybe you have to adjust them a bit:
cells = {'27/01/2012 15:30:00' 'TRADE' 58.2000000000000
'27/01/2012 15:31:33' 'TRADE' 58.3749000000000
'27/01/2012 15:49:19' 'TRADE' 58.5600000000000
'27/01/2012 15:49:19' 'TRADE' 58.5400000000000
'27/01/2012 15:50:26' 'TRADE' 58.4900000000000
'27/01/2012 15:55:22' 'TRADE' 58.6054000000000 };
time_stamps = cell(size(cells,1)-1,2);
for i=1:size(cells,1)-1
a_1 = datenum(cells{i,1},'dd/mm/yyyy HH:MM:SS');
a_2 = datenum(cells{i+1,1},'dd/mm/yyyy HH:MM:SS');
time_stamps{i,1} = datestr(a_1:1/24/60/60:a_2);
%or use a oneliner
%time_stamps{i,1} = datestr(datenum(cells{i,1},'dd/mm/yyyy HH:MM:SS'):1/24/60/60:datenum(cells{i+1,1},'dd/mm/yyyy HH:MM:SS'));
time_stamps{i,2} = repmat(cells{i,3},size(time_stamps{i,1},1),1);
end
disp(time_stamps)

댓글 수: 1

Mate 2u
Mate 2u 2012년 2월 14일
Hi there, I will accept your answer, however it is my fault, if you have seen the new question I have posted I need the timestamp along with the corresponding price. Obvious error on my part. If you can look at the new question I have made it quite clear.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Mate 2u
Mate 2u 2012년 2월 13일

0 개 추천

Anybody? Help would be very much appreciated.

카테고리

도움말 센터File Exchange에서 Transaction Cost Analysis에 대해 자세히 알아보기

질문:

2012년 2월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by