1

Here is my code:

function varargout = Cartoonisation(varargin)
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...                 
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @Cartoonisation_OpeningFcn, ...
                       'gui_OutputFcn',  @Cartoonisation_OutputFcn, ...
                       'gui_LayoutFcn',  [] , ...
                       'gui_Callback',   []);

    if nargin && ischar(varargin{1})
        gui_State.gui_Callback = str2func(varargin{1});
    end

    if nargout
        [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    else
        gui_mainfcn(gui_State, varargin{:});
    end

function Cartoonisation_OpeningFcn(hObject, eventdata, handles, varargin)
    handles.output = hObject;
    guidata(hObject, handles);

function varargout = Cartoonisation_OutputFcn(hObject, eventdata, handles) 
    varargout{1} = handles.output;

The error that I get is:

??? function varargout = Cartoonisation(varargin)

Error: Function definitions are not permitted at the prompt or in scripts.

The name of my .m and .fig file is Cartoonisation.m and Cartoonisation.fig

jilles de wit
  • 7,060
  • 3
  • 26
  • 50
  • 3
    Given the error message, my guess would be that you have other commands before your function definition (related questions are: http://stackoverflow.com/questions/5972184/matlab-error-function-definitions-are-not-permitted-in-this-context, http://stackoverflow.com/questions/5969547/how-to-correct-function-definitions-are-not-permitted-at-the-prompt-or-in-scrip, http://stackoverflow.com/questions/5363397/in-matlab-can-i-have-a-script-and-a-function-definition-in-the-same-file and http://stackoverflow.com/questions/1695365/whats-the-difference-between-a-script-and-a-function-in-matlab) – Aabaz Feb 22 '12 at 09:13
  • Hi Aabaz, I don't have any other commands before my function definition. I've tried renaming my functions and files as well but nothing worked. It used to be able to run, until i edited my GUIDE interface design. Could it be that I accidentally did smth to the settings? Thanks – user1225174 Feb 22 '12 at 11:03
  • I did not understand that you were reffering to a GUI built with GUIDE. I suggest that you edit your question to add more details on the context (what is the purpose of the GUI, how did you build it and what did you modify) and maybe to give the fig file for people with more knowledge about GUIDE than myself to test it out. – Aabaz Feb 23 '12 at 14:49

1 Answers1

0

here is the problem:

you have 3 functions in one function file.

Place each function in their own file named "functionNameHere.m" for each function.

Adam Hess
  • 1,396
  • 1
  • 13
  • 28