Possible duplicate:
In MATLAB, can I have a script and function definition in the same file?
Can I have code and MATLAB script code in the same file?
%% SAVED IN FILE myfunc.m (otherwise fail)
function [out1] = myfunc( x )
out1 = sqrt( 1 + (cos(x))^2 );
end
%%
%OTHER CRAP
y = 1:10
% use myfunc
This does not seem to work, even with the keyword end. Is this type of thing allowed or do I always need to have the EACH function in my own properly named file?
I'm sure I saw functions and code that use these functions in one file a couple of years ago.
source
share