필터 지우기
필터 지우기

Even vs Odd Vector

조회 수: 8 (최근 30일)
Kratos
Kratos 2014년 9월 4일
답변: Joseph Cheng 2014년 9월 4일
write a function that outputs a vector of only the odd indices of the input vector if that input's length is odd. if the input's length is even, then output a vector of its even indices. So if you input os [1 2 3 4 5 6], then your output should be [2 4 6]; if your input i s[1 2 3 4 5 6] then you should output [1 3 5].
  댓글 수: 3
Joseph Cheng
Joseph Cheng 2014년 9월 4일
편집: Joseph Cheng 2014년 9월 4일
Done, now what? All joking aside what have you tried? A hint to start would look at the function mod(). Also i think your last odd length example is wrong.
Kratos
Kratos 2014년 9월 4일
Honestly I don't even know how to start the problem.

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

답변 (1개)

Joseph Cheng
Joseph Cheng 2014년 9월 4일
Start by looking at how to create functions then indexing arrays and my suggested mod() function.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by