The first part can easily be done as follows: subset = A(1:3:end, :);
To split the data, I can also use the following link http://www.mathworks.com/matlabcentral/answers/47707-how-can-i-randomly-divide-a-dataset-matrix-into-k-parts The last part is very important for me and I am stuck in that part
I made it finally, do you have any other suggestion?
a=magic(18)
subset=a(1:3:end,:)
based on this I will randomly generate BB as
bb=[1 3 6];
counter=0;
for i=1:1:length(bb)
row=bb(i);
for j=1:1:3
counter=counter+1;
dg(counter,1:1:size(a,1))=(a(3*(row-1)+j,:));
end;
end