what are the indices of the middle element of a matrix

5 次查看(过去 30 天)
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.

请先登录,再进行评论。

更多回答(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