Asked by dav
on 26 Sep 2013

Hi,

I am running a simulation program.

There, in every simulation run it creates a data set of size T. I would like to know if there's a loop I can use to divide this data set into 20 sub data sets of equal size and randomly choose a data set, among the 20 sub data sets, to be used in a different pat of the program.

any help is greatly appreciated.

Dav.

*No products are associated with this question.*

Answer by Azzi Abdelmalek
on 26 Sep 2013

Accepted answer

A=1:100 % Example data=reshape(A,[],20) % each column represent your part of data id=randi(20) random_vector=data(:,id)

Show 1 older comment

Azzi Abdelmalek
on 27 Sep 2013

I do not know what (sample a vector under sampling with replacement) means. The code pick randomly a vector from the 20 parts, but it can pick the same another time

Azzi Abdelmalek
on 27 Sep 2013

If you want to avoid repetition

A=1:100 % Example data=reshape(A,[],20) % each column represent your part of data [n,m]=size(data); id=randi(m) random_vector=data(:,id) data(:,id)=[]

dav
on 27 Sep 2013

thank you very much!

Log in to comment.

Answer by Jan Simon
on 27 Sep 2013

The question is not clear. You have T "data sets" (what ever this mean) and want to divide it in 20 "sets" of equal size. Is T dividable by 20? Should the new data sets contain repetitions, e.g. is this allowed:

aNewDataSet = [T(1), T(1), T(3:end)]

Should the new data sets be elementwise distinct or is this allowed:

newDataSet(1) = [T(1), T(3:10)] newDataSet(2) = [T(1), T(4:11)]

When only one data set is used afterwards, why creating 20 of them at first?

Log in to comment.

Related Content

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments

Log in to comment.