How do I write an expression that refers to only the elements that have odd-number/odd-number index subscripts in a vector?

조회 수: 30 (최근 30일)
I first established a varibale
myend = randi([2,6])
I then established a vector based on this random interger
myvec = 0:0.5:myend
how would I write an expression to show the elements that have an odd-number subscript/odd-number index in the vector myvec?

답변 (1개)

cr
cr 2021년 9월 7일
Is this what you are looking for?
myvec(1:2:end)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by