help-octave
[Top][All Lists]
Advanced

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

Re: passing and modifying structures in mex octave functions


From: Ben Abbott
Subject: Re: passing and modifying structures in mex octave functions
Date: Sat, 26 Nov 2011 11:56:24 -0500

On Nov 26, 2011, at 10:59 AM, hafedh trigui wrote:

> From: Ben Abbott <address@hidden>
> To: hafedh trigui <address@hidden> 
> Cc: "address@hidden" <address@hidden>; "address@hidden" <address@hidden> 
> Sent: Friday, November 25, 2011 6:23:18 PM
> Subject: Re: passing and modifying structures in mex octave functions
> 
>> On Nov 25, 2011, at 2:58 PM, hafedh trigui wrote:
>> 
>> > Hi Ben,
>> >  
>> > I wanted to pass a structure into a mex file and modify its fields as 
>> > required by the algorithm.
>> > In my full code, the same structure will be passed to many C++ functions 
>> > and modified as required. I only attached a snapshot of the code (Visual 
>> > Studio C++ 2005) highlighting the problem.
>> > The test.m function (in debug directory) specifies the structure to be 
>> > passed to the mex function.
>> >  
>> > I'll greatly appreciate your help.
>> >  
>> > Thank you in advance,
>> > Hafedh
>> 
>> I'm not familiar with this subject, but I noticed there is a section in the 
>> manual on this subject. An example is included.
>> 
>>     
>> http://www.gnu.org/software/octave/doc/interpreter/Structures-with-Mex_002dFiles.html
>> 
>> My c/c++ experience is very limited (close to nil). I expect you'll be able 
>> to solve your problem faster than I can, but if the link above doesn't help, 
>> I can give it a try.
>> 
>> Ben
> 
> Thank you very much Ben. I have indeed looked at this example as well as the 
> matlab example phonebook.c where it is possible to read a structure and 
> re-write it in another form or change its type to cell.
> In my example, I'd like to pass a structure array to other C++ function and 
> my problem is that other than mexFunction, the other functions do not 
> recognize the same variable as a Structure array.
> I'll greatly appreciate your help or Arnaud help or anyone else from Octave 
> communauty.
> Thanks again
> Hafedh

You'll need to provide us with more information. 

How did you declare the structure array?

Did you include the necessary files? I'm not sure which one are needed, but I'd 
start with "mex.h" ...

        #include "mex.h"

... if that isn't enough, my next *guess* would be to add

        #include <octave/ov-struct.h>

But, I really am just guessing since I'm not a c/c++ programmer and have no 
experience mexing with Octave.

Did you encounter an error with compiling or when running your example? In 
either case, what exactly was the error?

Debugging this by email may be difficult unless some one knowledgeable notices 
this thread. You may wan to try Octave's chat room.

        http://www.gnu.org/software/octave/chat.html

Ben



reply via email to

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