A=[1 2 3; 1 2 5; 1 2 3;...
     1 3 1; 1 3 1; 2 1 1;...
     2 1 1; 2 1 2; 2 1 2]
then the result will be:
B=[1 2 11; 1 3 2; 2 1 6]
My own code is :
m=length(A);
for i=1:m-1
if A(i,1)==A(i+1,1) && A(i,2)==A(i+1,2)
A(i,3)=A(i,3)+A(i+1,3)
else
   A(i,3)=A(i,3)
end
end
But it's not working!
I appreciate if you could help me!
one of the many solutions
     ac=accumarray(A(:,1:2),A(:,3));
     [ir,ic,iv]=find(ac.');     % <- note the transpose...
     r=[ic,ir,iv]
%{
%    r =
          1     2    11
          1     3     2
          2     1     6
%}
us
:(...
   
"us " <u...@neurol.unizh.ch> wrote in message <h2gf2f$6n5$1...@fred.mathworks.com>...
Try this:
[UnA,dum,idx] = unique(A(:,1:2),'rows') 
V = accumarray(idx,A(:,3)) ;
Result = [UnA V]
hth
Jos