financial time series object - how to delete a column?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
One might have:
dt =
desc: (none)
freq: Daily (1)
'dates: (2715)' 'times: (2715)' 'Open: (2715)' 'High: (2715)' 'Low: (2715)' 'Close: (2715)' 'Vol: (2715)' 'OI: (2715)'
'19-Mar-2006' '22:00' [ 1164.25] [ 1186.5] [ 1160.5] [ 1183.75] [ 1149131] [ 1064369]
With both a dates and a times column ... to remove the times column one could think of:
dt_Close = fints(dt.dates, fts2mat(dt.Close))
This removes the times but gives only one column back ... I'd like to keep all columns and remove only the "times" column. So:
Is column indexing by column position (instead of column name) possible? This can be done for rows as:
dt([1 2 3]) % get only first 3 rows
dt([1 3:end]) % skip row 2
as described in another post here .... how can this be done for columns?
0 comentarios
Respuesta aceptada
dpb
el 17 de Mzo. de 2017
Editada: dpb
el 18 de Mzo. de 2017
It's essentially just a structure so rmfield is implemented as is for a struct object. Ain't the easiest thing to find that out in the documentation, but if you go to the root page and then the 'Functions' link you'll find it...
You can, of course, address the column as
dt.times=[];
to remove the data but there's still an empty field that way.
ADDENDUM
Per the doc, it appears the only way to not have the times series is to pass only a date vector containing no time values...with a series of integer datenum, the first example for fints shows only a dates series.
NB: however, if the data are lacking time information and there are multiple elements for a given day, the internal logic will remove all except the first instance of each day from the resultant time series created--iow, a time series by definition can contain only a single observation at a given time.
So the answer to the question is "you can't" but you can avoid creating the times series initially (in which case you won't have any need to remove it. :) )
3 comentarios
dpb
el 17 de Mzo. de 2017
OK, the times field is an unremovable property of the object...the date field was listed in the doc as always present but didn't see that the time was. Clearly, the error tells you it is.
The behavior is like a structure in many ways re: its syntax but it is not a user-definable structure wherein you can put whatever fields in you wish but a compiled class for which you have some flexibility but not unlimited. Looks like you just have to live with a time field; you can zero it out or perhaps you can even have an empty content, but the name is required.
Más respuestas (1)
Ver también
Categorías
Más información sobre Platform and License en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!