How to randomly select entire row from matrix?
12 views (last 30 days)
Show older comments
Hello! I have a matrix of size 198220*15, which contains year and physical characteristics of this year. And I need to randomly select a 100 rows from it, but it should be entire row selected randomly, so that the year and it's characteristics didn't mess up during this process.
I tried:
k = randperm(size(kx3,1));
mnew = kx3(k(1:100),:);
but it just selects independantly from each column, so characteristics of year 2003 go to year 2011, etc.
Thank you in advence!
0 Comments
Answers (1)
Wayne King
on 29 Nov 2013
A = randn(198220,15);
idx = sort(randperm(size(A,1),100));
B = A(idx,:);
2 Comments
See Also
Categories
Find more on Time Series in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!