MATLAB: How to create a loop to create columns based on an index number

data parsingindexingloops

I have data that looks like the following:
Ticker Return Index
1/1/2013 AAPL -.5% 1

1/2/2013 AAPL 1.0% 1
...
1/1/2013 GOOG .5% 2
1/2/2013 GOOG -.5% 2
How to I set this up so that each index numbers returns becomes a column? So like:
AAPL GOOG
1/1/2013 -.5% .5%
1/2/2013 1.0% -.5%

Best Answer

findgroups() on the dates. Use the returned values together with the Index as the first argument to accumarray() with the second argument being the return. The result will be an array of data.