Filter löschen
Filter löschen

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.

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 3 Dez. 2018
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);

Weitere Antworten (1)

Weisz Thomas
Weisz Thomas am 4 Dez. 2018
function h= zero_middle(h)
h(end/2+1/2,end/2+1/2)=0;
end

Kategorien

Mehr zu Adding custom doc finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by