I have a cell array in MATLAB as follow, the first column is a list of user ID:
A = { 'U2', 'T13', 'A52';
'U2', 'T15', 'A52';
'U2', 'T18', 'A52';
'U2', 'T17', 'A995';
'U4', 'T18', 'A53';
'U4', 'T13', 'A64';
'U4', 'T18', 'A64';
....
}
I also have a cell array B contains the unique ID for user as follow:
B = {'U2', 'U4'}
My goal is try to randomly select two samples for each user. Assume each user at least have two samples in B.
One example is the C as follow:
C = { 'U2', 'T13', 'A52';
'U2', 'T18', 'A52';
'U4', 'T13', 'A64';
'U4', 'T18', 'A64';
...
}
How to generate those sample?
forloops. Any faster way?