필터 지우기
필터 지우기

what are the indices of the middle element of a matrix

조회 수: 5 (최근 30일)
Weisz Thomas
Weisz Thomas 2018년 12월 1일
댓글: Walter Roberson 2018년 12월 3일
Write a function called zero_middlethat takes an n-by-mmatrix
as an input where both nand mare odd numbers (the function does not have
to check the input). The function returns the input matrix with its center
element zeroed out.

채택된 답변

Walter Roberson
Walter Roberson 2018년 12월 1일
hint: end/2+1/2
  댓글 수: 4
Weisz Thomas
Weisz Thomas 2018년 12월 3일
i am still a begginer and i have tried to follow your hints but now i have removed the output argument from my function because i don't know what value to assign to it. this is how my function looks:
function zero_middle(h)
[r,c]=size(h);
for ii=1:r
for jj=1:c
if mod(r,2) && mod(c,2)
h(end/2+1/2)=0;
end
end
end
end
please help me perfect it.
Walter Roberson
Walter Roberson 2018년 12월 3일
output is h
you do not need any loop or any tests.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by