> What's wrong with this Matlab function?

What's wrong with this Matlab function?

Posted at: 2014-12-18 
Your code appears to be getting rid of rows, not columns. edf203's answer gives you a start, but you've still never defined new. Try adding new = image; as a first line. Also, here's a faster way to do it:

Getting rid of odd rows:

new = image(2:2:end, :);

Getting rid of odd columns:

new = image(:, 2:2:end);

Instead of "n=mod(row, 2)==1", try "if mod(row, 2)==1". You also might want to use "row" instead of "n" in the next line. Also, don't forget to end that if statement.

function [ new ] = pixel( image )

[r,c]=size(image);

for row=1:r

n=mod(row,2)==1

new(n,:)=[];

end

end

Basically, I'm trying to get rid of every odd column. What's wrong with this formula?