"Roger Stafford" wrote in message <iqsgan$j9u$1@newscl01ah.mathworks.com>...
> "jrockv6e" wrote in message <iqsdcv$b41$1@newscl01ah.mathworks.com>...
> > This is a picture of a simple example of what I want to do.
> >
> > http://i.imgur.com/eZlED.png
> >
> > Where Y, F, and W are matrices.
> >
> > My initial idea is to combine all the elements in each row of F into a single number. I have looked at concatenating but it doesn't seem to do what I want.
> >
> > So that would give me,
> > e = [111; 111; 222; 222]
> >
> > and then I need to find the corresponding values of Y and W that fall within the group 111 to do the operation.
> >
> > I'm heading in the right direction? any hints would be greatly appreciated. Thanks for looking!
>          
> I have trouble understanding exactly what you want. The following seems the most likely solution, but if that is not correct, you need to expand considerably upon what you wrote. In particular your array 'e' does not seem compatible with the referenced file, "eZlED.png".
>
> [u,~,n] = unique(F,'rows');
> C = accumarray(n,Y,[length(u),1]) ./ accumarray(n,W,[length(u),1]);
>
> Roger Stafford
Thanks Roger that does the job. I guess there was no need for 'e'.
Is there a reason why the output has a 'NaN' ? This is what I have.
Y=[1; 2; 3; 4; 5];
F = [1 1 1; 1 1 1; 1 1 1; 2 2 2; 2 2 2];
W= [9; 8; 7; 6; 5];
[u,z,n] = unique(F,'rows');
C = accumarray(n,Y,[length(u),1]) ./ accumarray(n,W,[length(u),1])
C =
0.2500
0.8182
NaN
