copy some cells from 1x10 array to another array

I have got the following: x = [1 3 5 7 9 10 11 12 13 14]; and I would like to make a new table which will contain only the odd cell content. This means I would like to have a table looking like that: x_1 = [1 5 9 11 13];
Is there an easy way to do that besides using a for loop? If not, how can I perform this into a for loop?

댓글 수: 1

"Is there an easy way to do that besides using a for loop?"
By doing the MATLAB introductory tutorials, which show how basic indexing works:

댓글을 달려면 로그인하십시오.

 채택된 답변

Stephan
Stephan 2018년 8월 31일
편집: Stephan 2018년 8월 31일

0 개 추천

Hi,
the content of all odd indices you get by using this:
x1 = x(1:2:end)
Thats what your example says. If you want all odd content you need another code. Since your example appears to be meant for odd indices, i think you got what you wanted.
Best regards
Stephan

추가 답변 (1개)

카테고리

도움말 센터File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

질문:

2018년 8월 31일

편집:

2018년 8월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by