MATLAB Answers

## This question I found in internet please help me to solve this question.

sharad tiwari

### sharad tiwari (view profile)

님이 질문을 제출함. 21 May 2015
최근 활동 Jan

### Jan (view profile)

님이 댓글을 추가함. 7 Jun 2017
Thomas Koelen

### Thomas Koelen (view profile)

님이 답변을 채택함.
Write a function called odd_index that takes a matrix, M, as input argument and returns a matrix that contains only those elements of M that are in odd rows and columns. In other words, it would return the elements of M at indices (1,1), (1,3), (1,5), …, (3,1), (3,3), (3,5), …, etc. Note that both the row and the column of an element must be odd to be included in the output. The following would not be returned: (1,2), (2,1), (2,2) because either the row or the column or both are even. As an example, if M were a 5-by-8 matrix, then the output must be 3-by-4 because the function omits rows 2 and 4 of M and it also omits columns 2, 4, 6, and 8 of M.

James Tursa

### James Tursa (view profile)

21 May 2015
Please make an attempt and post your code. Then we can offer advice and suggestions.

로그인 to comment.

## 답변 수: 1

Thomas Koelen

### Thomas Koelen (view profile)

님의 답변 21 May 2015
채택된 답변

I strongly feel like this is homework.. but:
function M_out = odd_index(M)
M_out = M(1:2:end, 1:2:end);
end

Tyler Hoang

### Tyler Hoang (view profile)

17 Mar 2017
It should be 2:2:end, 2:2:end
James Tursa

17 Mar 2017
Is 2 odd?
Jan

### Jan (view profile)

7 Jun 2017
@soummya roy: ???

로그인 to comment.

Translated by