Effacer les filtres
Effacer les filtres

Select some elements from a given matrix

2 vues (au cours des 30 derniers jours)
Cladio Andrea
Cladio Andrea le 25 Mar 2015
Modifié(e) : James Tursa le 25 Mar 2015
Hello everyone, I have a matrix something like
m=[0.34,0.000009,0,2, 0,0.4,0.00087];
what i want is to pick randomly 3 elements from that matrix, i am really stuck , can anyone help?

Réponse acceptée

James Tursa
James Tursa le 25 Mar 2015
Modifié(e) : James Tursa le 25 Mar 2015
Assuming you don't care about the order in which they are selected:
m(randperm(numel(m),3))
If you want to preserve the original ordering, then:
m(sort(randperm(numel(m),3)))

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by