i'am writing a function the takes an n-by-m matrix as an input and returns the input matrix with the center element zeroed out. when i run it, it is giving the error:' not enough input arguments' in line two. can anybody assist me please.

2 次查看(过去 30 天)
function zero_middle(h)
[n,m]=size(h);
for ii=1:n;
for jj=1:m;
if mod(ii,2) && mod(jj,2);
h(end/2+1/2)=0;
end
end
end
end

采纳的回答

Walter Roberson
Walter Roberson 2018-12-3
You are trying to run your code by pressing the green Run button . You need to go down to the command line and invoke the code instead . Like
mm = magic(9);
zm = zero_middle(mm);

更多回答(1 个)

Weisz Thomas
Weisz Thomas 2018-12-4
function h= zero_middle(h)
h(end/2+1/2,end/2+1/2)=0;
end

类别

Help CenterFile Exchange 中查找有关 Adding custom doc 的更多信息

标签

产品


版本

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by