MATLAB: Splitting data array into sub arrays

MATLABsplittingsplittingdatasubarrays

Hi, I want to split the data of an array by the first 2 numbers of each data. This is to split firms by the first 2 digit of their SIC codes.
Example: 3301 would be in the sub array 33 which would represent a sector.
Any suggestions would be helpful.
Regards,
Frank

Best Answer

>> SIC=[3301, 4502, 3306, 4602, 4510].';
>> splitapply(@median,SIC,findgroups(fix(SIC/100)))
ans =
3303.50
4506.00
4602.00
>>
NB: The use of mod above was in error, dunno how I came up with that, but as long as they're all four-digit codes, the above should be about as easy as it gets.