help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: independent variable in function for leasqr


From: David Bateman
Subject: Re: independent variable in function for leasqr
Date: Tue, 10 Jul 2007 12:35:13 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Guillem Borrell Nogueras wrote:
> It is much better to use an anonymous function to fit this purpose.
>
> In this case would be:
>
>   
>>> k = 2 
>>> f = @(x) k*x^2
>>>       
>
>   
Well, for Matlab this is true, as the inline functions use Matlab's
object class whereas anonymous functions are in the matlab
parser/interpreter itself. So under Matlab anonymous functions are
significantly faster to use than inline functions. However, under Octave
inline functions are just a special type of anonymous functions and so
there is no speed disadvantage.

That being said, yes it is still better to use anonymous functions as
then you'll have better performance if you share your code with users of
the other product... Also, the way "inline" finds what are the arguments
of the function are, is a horrible mess which Octave had to copy for
compatibility.  Anonymous functions have a much cleaner interface (i.e.
you are required to define the arguments)..

D.


> To make this thing work you must upgrade to octave 2.9.x.  In earlier 
> versions 
> of octave the anonymous function won't find the constant k.
>
> You can find more information about anonymous functions and function handles 
> here: http://www.mathworks.com/access/helpdesk/help/techdoc/matlab.html.  
> look for anonymous functions in the index.
>
> guillem
>   


-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

[Prev in Thread] Current Thread [Next in Thread]