0

I defined the following function in matlab:

function draw_snake(snake,food)

but matlab shows me an error message saying:

Error: Function definitions are not permitted in this context.

I am new to matlab and just installed it.

I am using MATLAB version 8.1.0.604.

Jens Mühlenhoff
  • 14,565
  • 6
  • 56
  • 113
user94533
  • 3
  • 2
  • 2
    And what is the context? – doctorlove Oct 05 '13 at 12:45
  • possible duplicate of [How to correct "Function definitions are not permitted at the prompt or in scripts"](http://stackoverflow.com/questions/5969547/how-to-correct-function-definitions-are-not-permitted-at-the-prompt-or-in-scrip) – P0W Oct 05 '13 at 12:51

1 Answers1

0

See here The docs say

"function [y1,...,yN] = myfun(x1,...,xM) declares a function named myfun that accepts inputs x1,...,xM and returns outputs y1,...,yN. This declaration statement must be the first executable line of the function."

So,

function draw_snake(snake,food)

must be the first line in a script called draw_snake.m

Community
  • 1
  • 1
doctorlove
  • 18,872
  • 2
  • 46
  • 62