The short answer is no; MATLAB classdef M files are intended only for defining objects, and not for creating complete programs.
The long answer: you can get specific behavior from your classdef function if, for example, you overload the constructor to accept a flag that determines whether to act as a variable or act as a program.
eg.
classdef myClass ... methods function self = myClass(varargin) if nargin == 1 && strcmpi(varargin{1},'run') ..... %run the program else ..... %make the variable
OR you can create a static main method:
methods (Static = true) function main() %enabes: myClass.main() ... end
The IDE still does not know what to do with your M file to “run it,” but you can run it from the command line or another M file.
This last sentence is not 100% consistent - as Egon pointed out below, you CAN make the MATLAB IDE run this code - use the "launch configuration": http://www.mathworks.com/help/matlab/matlab_prog/run-functions-in- the-editor.html
source share