Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 13 Dec 2007 12:05:11 -0600
Date: Thu, 13 Dec 2007 11:05:09 -0700
From: Dan Hensley <somewhere@over.there>
User-Agent: Thunderbird 2.0.0.9 (Windows/20071031)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: #include in matlab?
References: <fjreq3$t02$1@fred.mathworks.com>
In-Reply-To: <fjreq3$t02$1@fred.mathworks.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <GKGdnewfyaHK6fzanZ2dnUVZ_gWdnZ2d@comcast.com>
Lines: 47
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 71.237.126.83
X-Trace: sv3-9ENjHq4JJ9YZemwSXzA7iIhIi8AiBCApS+YVlsGIeclFdKlEZQcCu7q/oklVlDTp7b+d913kGBwR3Pv!8Z5SOAOsvgADBr9nVP4RiDvwa6yMrSwAKxQEKWSaLBMD56puVEEwRU6dK2m6/sxWC00cjvJHQ1dB!Q1mV+z4ITYj6DAphsSVUK7pR830jIg==
X-Complaints-To: abuse@comcast.net
X-DMCA-Complaints-To: dmca@comcast.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.36
Bytes: 2254
Xref: news.mathworks.com comp.soft-sys.matlab:442377



Gus wrote:
> I have an m file that's exceeding 6000 lines and I want to
> split it up into many separate function files so I can more
> readily browse them.
> 
> Is there any way that I can create a file and somehow
> include it in the execution path so that I can still create
> function handles to subfunctions in that file from another m
> file?  Effectively, I want something like #include that I
> can use to split up a file up for a single program.

Here's another suggestion that I use a lot when I want to include a 
"library" of functions included in another .m file.


Your "library":

-------------------------------------
function h = myLibrary;

h.func1 = @func1;
h.func2 = @func2;

function out = func1(in1,in2)
% your code

function varargout = func2(varargin)
% etc.
-------------------------------------


Now in your calling function:

function myFunction

% Get the handles from the library
h = myLibrary;

% use one of them

in1=1; in2='string';
out = h.func(in1,in2);




Dan