Changing time intervals
2 ビュー (過去 30 日間)
古いコメントを表示
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
2012 年 2 月 13 日
Please explain any details of the wanted procedure. Which values do you expect after the "change"?
採用された回答
Friedrich
2012 年 2 月 14 日
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 件)
参考
カテゴリ
Help Center および File Exchange で Transaction Cost Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!