MATLAB: MATLAB on ramp, section 5.2, further practice.

arrayindexing

How can I access non-consecutive indices in a row vector? For e.g elements 1,3 and 6 in a column vector of 7×1

Best Answer

x = [1 2 3 4 5 6 7].'; % 7x1 vector
y = x([1 3 6]);