How to concatenate data points

I am trying to do a Monte Carlo analysis where I have to concatenate some data points and I'm kind of stuck on how to do that.
My code goes something like this (edited for length):
1) I have a 4-column data vector with ~30,000 rows. The columns are year, month, day, and precipitation amount.
2) I fit a GEV distribution to the precipitation vector and determine the 50% quantile
3) I reshuffle the data in 2-day chunks using mixed odd or even parity and re-fit the GEV and redetermine the quantile.
4) I repeat step 3 1000 times.
I have most everything else working except for how to concatenate my data points into 2-day chunks. I'm using a random number generator to randomly select odd or even parity but I'm not sure of the syntax to use for how to make the program shuffle them in groups of 2.

Réponses (1)

Matt Fig
Matt Fig le 5 Oct 2012
Modifié(e) : Matt Fig le 5 Oct 2012

0 votes

I am a little uncertain that this is what you want. But just to get started is this solving the actual problem?
A = reshape(1:24,8,3) % Given array.
% Now reorder rows by groups of two.
B = mat2cell(A,ones(1,4)*2,3);
B = B(randperm(4));
B = vertcat(B{:})
If so then a faster approach would be:
A = reshape(1:24,8,3) % Given array.
% Now reorder rows by groups of two.
m = size(A,1);
C = reshape(1:m,2,m/2);
C = C(:,randperm(m/2));
C = A(C(:),:)

1 commentaire

Anna
Anna le 8 Oct 2012
It's an idea but I really need the matrix to retain the same length. I also tried the "vertcat" function but that is not working out.

Connectez-vous pour commenter.

Question posée :

le 5 Oct 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by