MATLAB Answers

select 2 rows in a (n,m) matrix

17 views (last 30 days)
jaah navi
jaah navi on 4 Jan 2018
Commented: Rik on 5 Jan 2018
what command can be used to select 2 rows in a matrix(10,10),3 rows in a matrix(10,10),4 rows in a matrix (10,10)

  0 Comments

Sign in to comment.

Answers (2)

KL
KL on 4 Jan 2018
Edited: KL on 4 Jan 2018
I suppose you want to randomly sample 1,2 or 3 rows from your matrix.
A = rand(10); % example
noRows = 1;
A_sample = A(randperm(size(A,1),noRows),:);

  0 Comments

Sign in to comment.


Torsten
Torsten on 4 Jan 2018
rowi = A(i,:);
selects the i'th row from the matrix A.
Does this help ?
Best wishes
Torsten.

  1 Comment

Rik
Rik on 5 Jan 2018
This is the solution they should be looking for. And knowing that i can be a vector.

Sign in to comment.

Sign in to answer this question.