import - Converting Data to Timeseries - MATLAB -


i have excel data in following format

ticker     date     price goog       1/1/12    100 goog       1/2/12    200 aapl       1/1/12     50 

etc.

i convert time series collection (or matrix of data) in following format:

date      goog   aapl   .... (variable number of tickers) 1/1/12     100     50 

as easier use in matlab calculations on it.

the way i've done in past, , dont believe efficient, run unique(tickers) function check how many tickers have, chop off data accordingly in loop. think inefficient (and ugly) larger data sets. hoping have better suggestion?

here's sample of previous attempts i've done on similar data assumes data sorted ticker:

[uniquesecurities, uniqueindex] = unique(tickers); numbersecurities = length(uniquesecurities); 

the above code tell @ location new ticker start (at every uniqueindex entry).

now assuming there same number of observations each ticker, can chop off data in manner:

numberobservations = whatever j = 0; secindex = 1:numbersecurities        newdatamatrix(:,secindex) = prices(j : j + numberobservations);     j = j + numbrtobservations; end 

now if have variable number of observations each security, instead of jumping "numberobservations" intervals, use uniqueindex defined above, and, in similar manner, chop indices between uniqueindex(k) , uniqueindex(k+1).

the reason i'm posting because dont believe being efficient, , in addition there default matlab way doing this? understand, databases give me data in above format (not best of formats!) , dont have control on format unfortunately.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -