Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR MATLAB

pass variable by reference to function in matlab

classdef myClass < handle
  properties
    data
  end
  methods
    function h = myClass(data)
      h.data = data  ;
    end
  end
end

% Then defining a function (which could be a method) like
function myFunction(h)
  h.data = h.data+2;
end

% lets you do something like
h = myClass(0);
myFunction(h);
h.data
ans =
   2
 
PREVIOUS NEXT
Tagged: #pass #variable #reference #function #matlab
ADD COMMENT
Topic
Name
1+8 =