How to randomly extract 10 elements from that matrix
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i generate 1000*1 matrix through 'A=rand(100,1)'. And now i want to randomly extract 10 elements from that matrix.
How can i get that?!
0 Kommentare
Antworten (1)
Dyuman Joshi
am 12 Mai 2023
A = rand(1000,1);
%10 random indices less than or equal to the number of elements in A
idx = randperm(numel(A),10)
out = A(idx)
2 Kommentare
Dyuman Joshi
am 14 Mai 2023
"out" is just the variable to which I have assigned the output. You can change the name of the output as per what you want.
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!