From help-octave-request at bevo dot che dot wisc dot edu Thu Feb 5 22:11:27 2004 Subject: Question about how to use an existing octave function in a cc code From: "John W. Eaton" To: Wen-shiang Chen Cc: help-octave at bevo dot che dot wisc dot edu Date: Thu, 5 Feb 2004 22:09:42 -0600 On 5-Feb-2004, Wen-shiang Chen wrote: | Sorry to ask such a newbie question! I have very limited knowledge about | c++ programming and just start to learn how to program under octave. | | My question is how to use existing octave functions, in this case, the | randn function, in my cc code? The m-file looks like the following, | x=y+randn(2,10); | and my incomplete cc code looks like the follwing, | DEFUN_DLD (mycc, args, ,) | { | Matrix x (2,10); | Matrix y (2,10); | | x=y+?? | } | | So could someone shed some light for me on how to write | x=y+randn(2,10); | in my cc code? Thanks! If you are using a recent version of Octave, then rand is available in liboctave. For the more general case of calling a function defined in a .m file or a .oct file, you should use one of the feval functions, which are declared in parse.h and defined in parse.y. jwe ------------------------------------------------------------- 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 -------------------------------------------------------------