MATLAB: Noob Question about Functions

cannot define a function on the command linefunction

So how come when I start my code with
function EA3()
I get a Error: function definitions are not permitted in this context. My friend started his code off with
function Assignment03
N=8;
L=[2 0 3 2 6 7 9 5];
.
.
.
.
I tried to mock this to play around with it but as soon as I press enter to go to line two after function it gives me that error. I have very little experience in Matlab so any help is highly appreciated. Thanks in advance.

Best Answer

Daniel - are you sure that you are starting your code off with the line `function EA3()`? Typically, this error message is because there is some code that appears before this line. For example, if the following is saved to a file named test.m
clc;
function EA3()
% etc.
I observe the same error message.
With the exception of comments, no code can precede the function signature.