Prev: marker size in scatter plot
Next: NEED help IEEE 802.16-2004 simulink model about parameter and model
From: forkandwait w on 22 Feb 2010 22:40 Hi I would like to sum a vector, say [ 1 1 1 2 2 2 ] to get [3 6]. I was thinking of using a matrix like [1 1 1 0 0 0; 0 0 0 1 1 1], but I would like to find a graceful way to create said matrix. Is there a matlab idiom for this? FYI, I am taking a 110 vector of 1 year age wide fertility rates and collapsing it by groups of 5. tx
From: Matt Fig on 22 Feb 2010 22:50 x = [ 1 1 1 2 2 2 ] sum(reshape(x,3,2)) Make the appropriate alterations for your problem.
From: forkandwait w on 23 Feb 2010 08:55
> x = [ 1 1 1 2 2 2 ] > sum(reshape(x,3,2)) > > Make the appropriate alterations for your problem. Oh duh. Thanks for the advice... |