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?
"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.
"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!
I've tried:
function taborttrend
x=load('data.txt');
V=diff(x,1);
trend(V)
"Erik Andersson" <annerk02@student.umu.se> wrote in message
<g0htfh$imr$1@fred.mathworks.com>...
> "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!
>
> I've tried:
>
> function taborttrend
> x=load('data.txt');
> V=diff(x,1);
> trend(V)
>
> But it doesn't work. Why?
This is like saying, "I tried to walk, but I fell. Why?"
There could be MANY reasons.
>
> I think your flux capacitor overloaded the triple value
of
> the third exigency. You might want to uplink with the
> fluid portion of the apogee.
>
> Or....post your error message. Whichever is easier.
>
This is what i get:
??? Error using ==> load
Argument must contain a string.
Error in ==> trend at 3
V=load(x);
Error in ==> taborttrend at 4
trend(x)
x in this case I want to be my vector V created in the
function taborttrend
>>
>> I think your flux capacitor overloaded the triple value
> of
>> the third exigency. You might want to uplink with the
>> fluid portion of the apogee.
>>
>> Or....post your error message. Whichever is easier.
>>
>
> This is what i get:
>
> ??? Error using ==> load
> Argument must contain a string.
>
> Error in ==> trend at 3
> V=load(x);
>
> Error in ==> taborttrend at 4
> trend(x)
>
> x in this case I want to be my vector V created in the
> function taborttrend
If you load your data in the outer function (taborttrend), then you do
not need to load the data inside your trend function. I would think you
want your trend function to take as an input the data itself. That
means, define the function as:
function <whatever your output variable is> = trend(V)
and eliminate the V=load(x) line.
Your taborttrend function has already done the V=load(x), so you can
then simply pass V to the "trend" function, like you are currently doing.
-Peter
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.