help-octave
[Top][All Lists]
Advanced

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

Re: Can a script of octave be incorporated into DLF?


From: Paul Thomas
Subject: Re: Can a script of octave be incorporated into DLF?
Date: Thu, 10 Jun 2004 23:58:11 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225

Yes!

Either look at fsolve or lsodes or

#include <octave/oct.h>
#include <octave/pager.h>
#include <octave/parse.h>

DEFUN_DLD (fevaldemo, args, ,
  "The feval demo.")
{
  octave_value_list retval;
  std::string myfunc = args( 0 ).string_value();      //get function name
  octave_value arg1 = args( 1 );
  octave_value_list fargs ( arg1 );                   //set argument
  octave_value_list fret=feval( myfunc , fargs , 1 ); //call function
  if ( error_state )
  {
     octave_stdout  <<  "could not find MYSUB";
     return octave_value( -1 );
  }
octave_value gtmp = get_global_value( "g" ) ; //get preset global value
  if ( error_state )
  {
     octave_stdout  <<  "could not find global variable g";
     return octave_value( -1 );
  }
  set_global_value(  "a"  ,  gtmp  );                 //set global value
return fret; }
which allows the folling

octave:4> global g=42;fevaldemo("sin",1)
ans = 0.84147
octave:5> global a
octave:6> a
a = 42
octave:7> function y=myfunc(x);y=sin(x);endfunction
octave:8> global g=42;fevaldemo("myfunc",1)
ans = 0.84147
octave:9> function y=myfunc(x);y=sin(x/3)+cos(x/2);endfunction
octave:10> global g=42;fevaldemo("myfunc",1)
ans = 1.2048

Paul T



address@hidden wrote:

Hi all,

Is it possible that in the Dynamically linked function, we can
call a octave script? In matlab, we can achieve it by calling
mexCallMATLAB(..., "func"). I was wondering if in octave, we
have similar interfaces. Thanks,

Jia



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------






-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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