From: james bejon on 13 Mar 2010 11:28 Dear All, I'm very new (like a few days) to MatLab, so please bear with me. I want to use AccumArray to aggregate some data. Suppose I have a 30x1 data source which is effectively grouped 1, 2,...,10, 1, 2,..., 10, 1, 2,...,10. I can then use something like indices = repmat([[1:10]', ones(10, 1)], 3, 1); summed = accumarray(indices, data); to aggregate it. But what if my data source is 30xn? I can't seem to extend it. Can someone help please?
From: Oleg Komarov on 13 Mar 2010 13:46 "james bejon" <jamesbejon(a)yahoo.co.uk> wrote in message <hngeel$1rg$1(a)fred.mathworks.com>... > Dear All, > > I'm very new (like a few days) to MatLab, so please bear with me. I want to use AccumArray to aggregate some data. Suppose I have a 30x1 data source which is effectively grouped 1, 2,...,10, 1, 2,..., 10, 1, 2,...,10. I can then use something like > > indices = repmat([[1:10]', ones(10, 1)], 3, 1); > summed = accumarray(indices, data); > > to aggregate it. But what if my data source is 30xn? I can't seem to extend it. Can someone help please? In general values should be supplied as a vector and the number of rows in the subs should match numel(values); n = 2; data = rand(30,n); indices = repmat((1:10).', 3*n, 1); summed = accumarray(indices, data(:)); Oleg
From: Oleg Komarov on 13 Mar 2010 13:59 You also may be interested in my Pivot function: http://www.mathworks.com/matlabcentral/fileexchange/26119-pivotunpivot Oleg
From: james bejon on 14 Mar 2010 04:11 Thanks for the reply, Oleg. I don't have MatLab on this computer, so can't experiment with your suggestions immediately. On first glance, however, I wonder if my question was clear enough. When I referred to a (30 x n) data matrix, I meant a 30 rows by n columns matrix. Is this what your answer refers to?
From: james bejon on 14 Mar 2010 04:53
I'm therefore expecting a (10 x n) output matrix |