help-octave
[Top][All Lists]
Advanced

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

Inline functions including pi


From: Nik Waldron
Subject: Inline functions including pi
Date: Fri, 25 Apr 2008 15:00:38 -0700 (PDT)

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?

The problem manifests itself for me in the fplot command

octave:18> fplot( 'sin(2*pi*x)', [0 1] )
error: `x' undefined near line 17 column 21
error: evaluating binary operator `.*' near line 17, column 19
error: evaluating argument list element number 1
error: called from `?unknown?'
error: evaluating assignment _expression_ near line 77, column 8
error: evaluating if command near line 74, column 3
error: called from `fplot' in file `/usr/local/share/octave/3.0.1/m/plot/fplot.m'

A similar message to what I get if I try to feval f without the 'pi' argument:

octave:18> feval( f, 1 )
error: `x' undefined near line 16 column 14
error: evaluating binary operator `*' near line 16, column 15
error: evaluating argument list element number 1
error: called from `?unknown?'

I'm pretty sure that this worked in an earlier version of octave.  Any advise would be appreciated.

Regards,



NIK WALDRON



Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
reply via email to

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