How to select non-sequential values in an array?

Q
Quincy · Nov 4, 2020 · 1.9K views
Question
I am trying to select the first, fifth, and ninth values of a 12x1 matrix. I am aware of how to reference sequential values like a(1:5,1) for the first five values but cannot figure out how to properly reference the non-sequential values. 
Expert Answer
Profile picture of Neeta Dsouza
Neeta Dsouza PhD Expert
Answered Aug 12, 2026

In MATLAB, you can select non-sequential values from an array using indexing. First, define your array and then create an index array with the positions of the values you want to select. Use this index array to extract the desired values. For example:

array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
index = [1, 3, 5, 7, 9];  % Non-sequential indices
selected_values = array(index);

This way, you can easily retrieve non-sequential elements from your array.

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!