help-octave
[Top][All Lists]
Advanced

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

Re: standalone application (octave to c++): define anonymous function fo


From: Doug Stewart
Subject: Re: standalone application (octave to c++): define anonymous function for nonlin_curvefit()
Date: Mon, 28 Jan 2019 08:15:48 -0500



On Mon, Jan 28, 2019 at 7:53 AM ola <address@hidden> wrote:
I have tried to declare:
octave_user_function f = @(p,x) 1-exp(p*x);
but I've got 1) error: stray address@hidden in program and 2) error: ‘p, x’ was not
declared in this scope

Why the octave interpreter doesn't understand @ sign?
How to properly declare an anonymous function or how to write a function
that will return an object octave_user_function?
Should I provide any additional headers (include <???>) when declaring
anonymous functions?
Maybe there is another way to transfer user function (@(p,x) 1-exp(p*x)) as
an argument for octave::feval?

It would be really great if I could use this function. My ideas for a
solution are exhausted. I need your help.



-----
ola
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



does this help

>>str1='@(p,x) 1-exp(p*x);'
     str1 = @(p,x) 1-exp(p*x);
>>fh=str2func(str1)
      fh = @(p, x) 1 - exp (p * x)
>> fh(2,4)
       ans = -2980.0

start with a string  use octave to convert it to a function handle and the use feval  from c++





--
DASCertificate for 206392


reply via email to

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