help-octave
[Top][All Lists]
Advanced

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

Re: Inline functions including pi


From: David Bateman
Subject: Re: Inline functions including pi
Date: Sat, 26 Apr 2008 03:46:02 +0200
User-agent: Thunderbird 2.0.0.12 (X11/20080306)

Nik Waldron wrote:
> Hi,
> 
> I'm in the process of porting some Matlab scripts for my personal use, I
> am using Octave 3.0.1.  I've had some problems with fplot, which I'll
> get to in a round about way.  If I define a simple inline trig function
> including pi and attempt to evaluate it I get the following:
> 
> octave:17> f=inline("sin(x*pi)")
> f =
> 
> f(pi, x) = sin(x*pi)
> 
> Octave has identified my function as having two variables (x and pi) as
> opposed to treating pi as a constant.  Is there any way to convince the
> interpreter that pi is a constant?

This is (or was) the documented behavior of the inline function when I
implemented it... I'd suggest writing the above instead as

f = @(x) sin (x*pi);

as inline functions in matlab are deprecated in favor of anonymous
function like the above, probably exactly for this reason of confusion
of what are the arguments. The above will work both in Matlab and Octave.

D.


reply via email to

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