Select every other element of a vector - MATLAB Cody - MATLAB Central

Problem 6. Select every other element of a vector

Difficulty:Rate
Write a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, starting with the first.
Examples:
Input x = [1 3 2 4 3 5]
Output y is [1 2 3]
Input x = [5 9 3 2 2 0 -1]
Output y is [5 3 2 -1]

Solution Stats

48.42% Correct | 51.58% Incorrect
Last Solution submitted on May 10, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
3

Group

BMEG309 Image
BMEG309
  • 10 Problems
  • 45 Finishers

Problem Recent Solvers34424

Community Treasure Hunt

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

Start Hunting!
Go to top of page