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.

 Respuesta aceptada

Geoff Hayes
Geoff Hayes el 13 de Feb. de 2017

0 votos

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.

3 comentarios

Yeah I am 100%. I just closed MATLAB and reopened it so it can be a new start and I started off my code as
function EA()
and it gave me the same error...
%
Kelly Kearney
Kelly Kearney el 14 de Feb. de 2017
It appears that you're typing this in the Command Window, which isn't allowed. Functions need to be written in their own file. To start, type edit EA.m at the command line to create a new file; you can then put all your code in this file.
Daniel Espinoza
Daniel Espinoza el 14 de Feb. de 2017
Thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Report Generator en Centro de ayuda y File Exchange.

Preguntada:

el 13 de Feb. de 2017

Comentada:

el 14 de Feb. de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by