[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: function help
From: |
Ben Abbott |
Subject: |
Re: function help |
Date: |
Thu, 23 Feb 2012 15:05:02 -0500 |
On Feb 23, 2012, at 10:47 AM, Ben Abbott wrote:
> On Feb 23, 2012, at 4:26 AM, Tom Bohdan <address@hidden> wrote:
>
>> I have had no success with finding why the following doesn't work. I have
>> tried many examples in Octave's Help and they don't work either.
>>
>> Why is it that if you type each line into the command line then the
>> following works:
>>
>> function total=addr(x,y)
>> total=x+y;
>> endfunction
>>
>> add(5,4)
>>
>> >ans=9
>>
>> but if i put the above lines into a m-file then the interpreter spits out x
>> undefined etc.
>>
>> This happens for all the functions i have found in the LSODE examples etc.
>> If you type them one by one at the command line it works but not in a script
>> file. What am i missing ???
>>
>> regards
>> Tom
>
> Did you intend "add()" or "addr()" ?
>
> Ben
Note, that if the lines below are in add.m, then add(x,y) calls that function.
function total=addr(x,y)
total=x+y;
endfunction
If the same lines are typed at the command prompt then add(x,y) is calling
something else ... likely a function saved in a file with the name add.m.
You can check by typing ...
which add
Ben
- Re: function help, (continued)
- Re: function help, damian.harty, 2012/02/24
- Re: function help, Doug Stewart, 2012/02/24
- Re: function help, Doug Stewart, 2012/02/24
- Re: function help, Ben Abbott, 2012/02/24
- Re: function help, Doug Stewart, 2012/02/24
- Re: function help, Ben Abbott, 2012/02/25
- Re: function help, Doug Stewart, 2012/02/25
- Re: function help, John W. Eaton, 2012/02/25
- Re: function help, Ben Abbott, 2012/02/25
- Re: function help, damian.harty, 2012/02/24
Re: function help,
Ben Abbott <=
Re: function help, Ben Abbott, 2012/02/23
Re: function help, Ben Abbott, 2012/02/23