Even vs Odd Vector
显示 更早的评论
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 个评论
Adam
2014-9-4
Is that just pasted straight from homework? People don't usually start a question looking for Matlab help with "write a function..."
What have you tried so far to solve this? It is a very simple problem that someone (including myself) could easily give you the answer to, but do you honestly not have any input yourself as to how you would go about doing this?
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
2014-9-4
回答(1 个)
Joseph Cheng
2014-9-4
1 个投票
类别
在 帮助中心 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!