Possible Duplicate:
In MATLAB, can I have a script and a function definition in the same file?
Can I have MATLAB script code and function 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
It doesn't seem to work, even with the end
keyword there. Is this type of thing allowed or do I always need to have EACH function in its own properly named file?
I'm sure I saw functions and code that uses those functions in the same file a couple years ago.