MATLAB on ramp, section 5.2, further practice.

6 views (last 30 days)
How can I access non-consecutive indices in a row vector? For e.g elements 1,3 and 6 in a column vector of 7x1

Accepted Answer

Ameer Hamza
Ameer Hamza on 27 May 2020
x = [1 2 3 4 5 6 7].'; % 7x1 vector
y = x([1 3 6]);
  1 Comment
Juan Manuel Bayona Arenas
Edited: Juan Manuel Bayona Arenas on 8 Sep 2020
THX. So. in Matlab 2020 not is raw vector. It´s a column vector. In this case, y = x([1;3;6]); 5.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!