Path: news.mathworks.com!not-for-mail
From: "helper " <spamless@nospam.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Call another function!
Date: Thu, 15 May 2008 17:51:02 +0000 (UTC)
Organization: Timothy S. Farajian, Inc.
Lines: 40
Message-ID: <g0ht66$17m$1@fred.mathworks.com>
References: <g0hsbt$bvj$1@fred.mathworks.com>
Reply-To: "helper " <spamless@nospam.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210873862 1270 172.30.248.35 (15 May 2008 17:51:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 May 2008 17:51:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1272923
Xref: news.mathworks.com comp.soft-sys.matlab:468657


"Erik Andersson" <annerk02@student.umu.se> wrote in message 
<g0hsbt$bvj$1@fred.mathworks.com>...
> I've got the following function:
> 
> function taborttrend
> x=load('data.txt');
> V=diff(x,1);
> 
> Now a want to call another function lying in the same 
> directory as taborttrend.m named trend.m which has input 
x, 
> i.e trend(x). Now a want my differenced vektor V to be 
that 
> input x and that its done in the m-file taborttrend. How 
do 
> a get that?
> 
> Thanks for answers!


If I understand your question right, you want to use:

function taborttrend
x=load('data.txt');
V=diff(x,1);
trend(V)

Note that when you call a specific function (as you are 
doing with TREND), it doesn't matter what the name of the 
input variable is within that function.  You can pass any 
variable you want.

If you defined TREND to be:

 function trend(x)

You don't have to call TREND using "x", however, within 
TREND, you must use "x" to reference the passed-in value.

I hope this addresses and answers your question.