My file testtest.m looks like :
pluse(1, 2)
function retval = pluse(input1, input2)
retval = input1 + input2;
endfunction
Then I get:
I had the same question/problem and some people gave the hints. But since there is no explicit example, I post it here so that other guys can find a explict running example both for Octave and MATLAB.
% works in Octave %%%
% sth. must be *before* a (local) function is declared
1; % or "2;" or "1+1;" or whatever
% local function must be declared *before* it is run in Octave
function retval = pluse(input1, input2)
retval = input1 + input2;
end % or "endfunction"
% Now you can use the local function
pluse(1, 2)
And there the the incompatibility between Octave and MATLAB because the MATLAB example does not run in Octave and vice versa:
% works in MATLAB %%%
% You can use the local function
pluse(1, 2)
% local function must be declared at the end of file for MATLAB
function retval = pluse(input1, input2)
retval = input1 + input2;
end
Because of this incompatibility the question is if one should really use local functions. Maybe one should use "normal" functions in a file...