getting first 20% of a matrix

5 vues (au cours des 30 derniers jours)
cormac spillane
cormac spillane le 27 Avr 2015
Modifié(e) : Stephen23 le 27 Avr 2015
I am getting the first 20% of a (290,2) matrix (so a 58,2 matrix). I was just wondering how this is possible. im presuming there are a number of ways but unsure as to how to do it?
  1 commentaire
Stephen23
Stephen23 le 27 Avr 2015
Modifié(e) : Stephen23 le 27 Avr 2015
What do you mean by the "first 20% of a matrix" ?
  • The first 20% of the rows, starting from the first row?
  • the first 20% of the columns, starting from the first column?
  • the first 20% of the elements, starting from the first element?
  • the first 20% of the values, when the values are sorted by value?
  • something else?

Connectez-vous pour commenter.

Réponse acceptée

Guillaume
Guillaume le 27 Avr 2015
Just use standard matrix indexing:
A = rand(290, 2); %for example;
B = A(1:floor(size(A, 1) * 0.2), :);

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