calling c++ or c from octave?

Bob Odom odom at apl.washington.edu
Wed Nov 5 13:00:26 CST 2008




On Wed, 5 Nov 2008, Jonathan Stickel wrote:

> On 11/5/08 help-octave-request at cae.wisc.edu wrote:
>>> From: Carlo de Falco <carlo.defalco at gmail.com>
>>>> Subject: Re: calling c++ or c from octave?
>>>> To: sergstesh at yahoo.com
>>>> Cc: help-octave at cae.wisc.edu, "Francis Poulin" <fpoulin at uwaterloo.ca>
>>>> Date: Wednesday, November 5, 2008, 6:39 AM
>>>> On 04/nov/08, at 19:57, Sergei Steshenko wrote:
>>>>
>>>>>> You may start from here:
>>>> http://wiki.octave.org/wiki.pl?CodaTutorial .
>>>>>>
>>>>>> I am using a different approach - I am writing data in
>>>> binary format from
>>>>>> "C" using "fwrite" and load the
>>>> data into 'octave' using 'fopen',
>>>> 'fread'
>>>>>> in 'octave'. Works like a charm.
>>>>>>
>>>>>> Regards,
>>>>>>  Sergei.
>>>>
>>>> if you only need to exchange data then "popen"
>>>> and
>>>> "fread" are probably an even better option
>>>> c.
>>
>> Well, in my case 'octave' does not call the "C" program and vice versa.
>> So, the "C" program dumps data into files and when I need to analyze them
>> by 'octave' I invoke it.
>>
>
> If all that is needed is to manage workflow, then perhaps the "system"
> function in octave would be helpful.  For example, you can do something
> like:
>
> octave> system("script_to_run_C_program")
> octave> read_in_C_data
> octave> [plotting commands]
>
>
> Jonathan
> _______________________________________________
> Help-octave mailing list
> Help-octave at cae.wisc.edu
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
I agree, the 'system' call works just fine. In my case the commands are:

octave> [s,w]=system( [ programdirectory '/program.exe < ' fname '.env >& ' fname '.prt' ] )
octave> (more stuff to process and plot the output from the "program.exe")

Bob


More information about the Help-octave mailing list