Hi How i can select randomly elements from a matrix o array I have the matrix and i want to select "x" numbers of elements
Neeta Dsouza answered .
2025-11-20
msize = numel(YourMatrix); idx = randperm(msize); YourMatrix(idx(1:x))
If you have a fairly new version of MATLAB, you can instead use
msize = numel(YourMatrix); YourMatrix(randperm(msize, x))