Problem 6. Select every other element of a vector
Solution Stats
Problem Comments

40 Comments
Not clear.
What does it mean? It is not clear
It's not understandable.
This problem is definitely not clear.
Select the first, the third, the fifth, the seventh, ... element.
nice problem
I cant understand this problem.
nice
All solutions with score 10 or 11 use the regexp cheat.
very good one
Yes, you should change the redaction of the problem,maybe
function y = everyOther(x)
for i=1:length(x)
if mod(x(i),2)~=0
y(i)=x(i)
end
end
y=y(y>0)
end
What's wrong with this solution?
y = x(mod(x,2)==1);
it's not working, and i cant see why
nice problem
nice
good
I can't understand, why is this wrong?
j=1;
for i=1:length(x)
if rem(x(i),2)~=0
y(j)=x(i);
j=j+1;
end
end
Nice problem, but I have been doing this with my son and it would be good if the exercises were more gently graduated with relevant syntax so he can learn without relying on his dad knowing Matlab!
I can't believe someone solved this with size 9.
The leading solution is not a solution. It just makes all the test assertions true.
Indexing is one of more important things in matlab and matrices. Gotta learn them good before heading on.
Helo, hey hey ey
Indexing is one of more important things in matlab and matrices. Gotta learn them good before heading on.
Test suite suggests solution !
nice
the example made confusion
cool!
nice!
cool!
hard
I overcomplicated this one at first, but once you figure it out, it's not too bad
Absolutely mind boggling
this one's pretty good
gg ez
I have a question is that :test6 and test7 is the column vector,but test15 is the row vector,
so if test 15 are passed ,the test 6 and 7 are not passed
这个问题出的有点问题，没有规范化
gg ez
OMG, It wasn't about finding the odd numbers?
Below is my code but it is failing the test 6 and 7. I tried inputting x=randi(100,10,1) and x=primes(20) in the scratchpad and the code works fine, outputing the right answer. There seems to be a problem with the evaluation of the answers.
function y = everyOther(x)
y = [];
for i = 1:2:length(x);
y(end+1) = x(i);
end
@Muhammad, take a deeper look at what the test cases are testing for.
Solution Comments
Show commentsProblem Recent Solvers32939
Suggested Problems

1551 Solvers

908 Solvers

8501 Solvers

Create an indexpowered vector
764 Solvers

497 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!