MATLAB: How to take part of vector

vector

Dear all; I have vector a=[1 2 5 66 7 88 9 0 23 12] and c=4; The question is , How can i take first 4 cell from vector a depend on c
result = [ 1 2 5 66];
Thanks for always helping me….

Best Answer

It is time for you to read the getting started tutorials about MATLAB. In there you will have learned to use indexing, and such basic ideas as the colon operator.
result = a(1:c);