From: us on 11 Feb 2010 12:31 "Tom De Temmerman" <tom_dt5(a)hotmail.com> wrote in message <hl1dhl$atc$1(a)fred.mathworks.com>... > Hi guys, > the problem is the following > > i have a table of this format (m by 3 matrix): > X Y count > 1 1 3 > 1 4 1 > 1 5 6 > 3 4 2 > 5 2 1 > 5 3 9 > 6 2 2 > ... > > the table is sorted first by X then by Y. Count is the frequency of X appearing in Y. > > and i want to turn this into the following matrix: > Y > 1 2 3 4 5 ... > X 1 3 0 0 1 6 > 3 0 0 0 2 0 > 5 0 1 9 0 0 > 6 0 2 0 0 0 > ... > for each X you now have only 1 row > > i'm an absolute beginner when it comes to matlab and I don’t know if this is even possible, so any help is much appreciated. > > regards one of the solutions m=[ 1 1 3 1 4 1 1 5 6 3 4 2 5 2 1 5 3 9 6 2 2 ]; ac=accumarray(m(:,1:2),m(:,3)) %{ % ac = 3 0 0 1 6 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 9 0 0 0 2 0 0 0 %} us
|
Pages: 1 Prev: Database tool for historical data Next: 3D reconstruction from image/scene |