I read the following table from mysql into a matlab cell array:
Nyse = fetch(conn,'SELECT ticker,date,utcsec,bid,ofr FROM HFE.Quotes where ex="N" order by utcsec,bid;');
The Nyse cell array contain 1000000 rows. And I want to calculate the median bid for each second, where the second is recorded as a string in the utcsec column. I do it in the following way:
utcsec=cell2mat(Nyse(:,3));
bid=cell2mat(Nyse(:,4));
NyseBid=grpstats(bid,utcsec,{'median'});
The problem is that the function grpstats takes around 70 sec to do the task. The question is, how can I optimize the code so it will run faster?
An example string in the UTCSEC column is '09:30:00'.