a = [1 2; 3 4; 5 6] I want to extract the first and third row of a, so I have x = [1; 3] (indices of rows).
a = [1 2; 3 4; 5 6]
a
x = [1; 3]
a(x) doesn't work.
a(x)
Like this: a([1,3],:)
a([1,3],:)
The comma separates the dimensions, : means "entire range", and square brackets make a list.
:
2.1m questions
2.1m answers
60 comments
57.0k users