Filter löschen
Filter löschen

Even vs Odd Vector

4 Ansichten (letzte 30 Tage)
Kratos
Kratos am 4 Sep. 2014
Beantwortet: Joseph Cheng am 4 Sep. 2014
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 Kommentare
Joseph Cheng
Joseph Cheng am 4 Sep. 2014
Bearbeitet: Joseph Cheng am 4 Sep. 2014
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 am 4 Sep. 2014
Honestly I don't even know how to start the problem.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Joseph Cheng
Joseph Cheng am 4 Sep. 2014
Start by looking at how to create functions then indexing arrays and my suggested mod() function.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by