MATLAB Answers

split data in a special manner

1 view (last 30 days)
Niki on 30 May 2014
Answered: Andrei Bobrov on 30 May 2014
I have a matrix named A (450*1102) 1- I want to take from each three objects (e.g. 3*1102), the first object (1*1102) to another set called B My new set will be B=150*1102
2- I split the objects from set B randomly myself for example B1= 1, 5, 8, 15 , ... B2= 2,3,4,6,7,9,10,11,12,13,14,...
Then I want to generate two sets called BF and BS BF is taking the B1 according to the Set A BS is taking the objects according to the set B
If you look above, the set B is generated based on set A (each three objects one of them to the set B) So when I want to generate the set BF, I want to use the B1 .Object 1 selected in B1 corresponds to object 1,2,3 of set A sample 2 in BS correspond to 2,3,4, etc

Answers (2)

Niki on 30 May 2014
Edited: Niki on 30 May 2014
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 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?
based on this I will randomly generate BB as
bb=[1 3 6];
for i=1:1:length(bb)
for j=1:1:3

Andrei Bobrov
Andrei Bobrov on 30 May 2014
bb=[1 3 6];
k = 3;
i0 = zeros(size(a,1),1);
i0(1:k:end) = 1;
out = a(ismember(cumsum(i0),bb),:);


Community Treasure Hunt

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

Start Hunting!