0

I hope to create such custom function

  function addnum(mat,n=numel(mat))
  mat+n

I mean I try to add a number into the element of mtrix mat,but if I don't give a explicit value for n,I hope the n will be the number of the mtrix self.

yode
  • 483
  • 7
  • 16

1 Answers1

0

As this answer,this is what I'm after

function addnum1(mat,n)
if nargin<2
    n=numel(mat);
end
mat + n
yode
  • 483
  • 7
  • 16