MATLAB: Cell and double data

cellcell arraysmatrix manipulation

Hello,
I have an excel file something like this:
Type Value
Type A 100
Type A 500
Type B 1000
I use xlsread to import data to matlab and i get two data types:
double
100
500
1000
and cell
Type Value
Type A
Type A
Type B
I need to read the "column Type" and then sum the "column Value", if the type is the same . The goal is to get something like this and than export to excel:
Type Value
Type A 600
Type B 1000
Can you help me?
Thanks.
Joao Rosa

Best Answer

Type={'Type A','Type A','Type B','Type C','Type C'}.';
Value=[100,500,1000,100,200].';
[UniType,Ind_i,Ind_j]=unique(Type);
SumValue=accumarray(Ind_j,Value)
xlswrite('test.xls',[UniType,num2cell(SumValue)]);
SumValue =
600
1000
300