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.
:
1.4m articles
1.4m replys
5 comments
57.0k users