Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news2.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!newsfe07.iad.POSTED!7564ea0f!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Organization: Canada Eat The Cookie Foundation
User-Agent: Thunderbird 2.0.0.18 (Windows/20081105)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: #include in matlab?
References: <fjreq3$t02$1@fred.mathworks.com> <GKGdnewfyaHK6fzanZ2dnUVZ_gWdnZ2d@comcast.com> <fklqlc$8mv$1@fred.mathworks.com> <gh4md4$a7r$1@fred.mathworks.com>
In-Reply-To: <gh4md4$a7r$1@fred.mathworks.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 35
Message-ID: <IklZk.3869$yB4.1025@newsfe07.iad>
NNTP-Posting-Host: 24.79.146.116
X-Complaints-To: internet.abuse@sjrb.ca
X-Trace: newsfe07.iad 1228267944 24.79.146.116 (Wed, 03 Dec 2008 01:32:24 UTC)
NNTP-Posting-Date: Wed, 03 Dec 2008 01:32:24 UTC
Date: Tue, 02 Dec 2008 19:32:36 -0600
Xref: news.mathworks.com comp.soft-sys.matlab:504558


Edward wrote:
> I don't understand why I can't use something more akin to #include. Is there any command
> that simply copies one '.m' file into another?

No, not when the .m file can contain function definitions. If it does not contain function
definitions, then you could use a "script".

> Dividing each function into an independent file is rather annoying. I would like to something
> like this:
> 
> "test.m":
> % Include statement for "testlib.m"
> function myfunc()
> add(2,3)
> multiply(2,3)
> end
> 
> 
> "testlib.m"
> function [out] = add(in1,in2)
> out = in1+in2;
> end
> 
> function [out] = multiply(in1,in2)
> out = in1*in2;
> end

Objects and methods then.


-- 
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?