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 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Weisz Thomas
le 2 Déc 2018
Commenté : Walter Roberson
le 4 Déc 2018
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
0 commentaires
Réponse acceptée
Walter Roberson
le 3 Déc 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);
0 commentaires
Plus de réponses (1)
Weisz Thomas
le 4 Déc 2018
1 commentaire
Walter Roberson
le 4 Déc 2018
Yup. And it so happens that under the circumstances imposed in the initial question, you could also use
h(end/2+1/2) = 0;
Voir également
Catégories
En savoir plus sur Adding custom doc dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!