Info
This question is closed. Reopen it to edit or answer.
How to use random arrangement for 2 related matrices?
1 view (last 30 days)
Show older comments
My 1st matrix contains characteristics of various car, with each row representing different car
My 2nd matrix contains class labels, containing only 1 column.
Now I want to randomly select rows from my 1st matrix, but while doing so I also want to select the corresponding values from 2nd matrix.
I am using the following code to select random rows from 1st matrix:
N=2; % no. of rows needed
Temp = randperm (length(A), N); % A is my 1st matrix
B=A(Temp, :) % B contains the random rows selected from A
0 Comments
Answers (1)
the cyclist
on 19 Jul 2018
Edited: the cyclist
on 19 Jul 2018
If C is your second matrix, then
D = C(Temp);
gives you the corresponding elements of C.
This seems so simple, though, the I worry I am missing something. Maybe you can post a specific example with actual matrices?
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!