Looking at following code:
x=[2,3;1,4;1,5;2,4;3,1;3,4];
u=unique(x(:,1));
for i=1:length(u)
n(i,:)=mean(x(x(:,1)==u(i),:))
end
Is there anyway to avoid the for
loop, and make the code simpler? Basically, what I want to do is to group the rows based on a the value of a column and apply an operation on the other values for a given "group".