Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Passing C struct out to Matlab space

Subject: Passing C struct out to Matlab space

From: panabiker

Date: 31 Jul, 2007 08:59:37

Message: 1 of 4

I have a need to see the content of a struct defined in a C-mex
program. I know there is a Matlab struct and if I really want, I can
copy the members of the C struct to Matlab struct but I really want to
avoid that. I also tried to simply set plhs[0] to the pointer to the
struct and it didn't work. It there a quick and dirty way that allows
one to see what's in a C struct in Matlab space?

Subject: Passing C struct out to Matlab space

From: Praetorian

Date: 31 Jul, 2007 16:49:23

Message: 2 of 4

On Jul 31, 9:59 am, panabiker <ghu...@comcast.net> wrote:
> I have a need to see the content of a struct defined in a C-mex
> program. I know there is a Matlab struct and if I really want, I can
> copy the members of the C struct to Matlab struct but I really want to
> avoid that. I also tried to simply set plhs[0] to the pointer to the
> struct and it didn't work. It there a quick and dirty way that allows
> one to see what's in a C struct in Matlab space?

There's no way to do what you want AFAIK. Matlab and C structs are
completely different, I remember reading someone's post here on a
similar topic that a Matlab structure would be more similar to a hash
table than a C structure. So you will have to copy over each member
from the C structure to the Matlab structure.

HTH,
Ashish.

Subject: Passing C struct out to Matlab space

From: us

Date: 31 Jul, 2007 16:59:13

Message: 3 of 4

panabiker:
<SNIP in need of insight on C/ML structures...

maybe this is helpful

http://www.mathworks.com/matlabcentral/newsreader/view_thread/149563#376294

in particular, follow the ref to <peter boettcher>'s post mentioned therein...

us

Subject: Passing C struct out to Matlab space

From: panabiker

Date: 31 Jul, 2007 12:42:20

Message: 4 of 4

On Jul 31, 12:59 pm, "us " <u...@neurol.unizh.ch> wrote:
> panabiker:
> <SNIP in need of insight on C/ML structures...
>
> maybe this is helpful
>
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/149563#...
>
> in particular, follow the ref to <peter boettcher>'s post mentioned therein...
>
> us

Thanks, I think this is a little deeper than I want to dig into at
this point. For now, I just copy the members to an array and pass the
array out.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
structure us 31 Jul, 2007 12:59:59
c us 31 Jul, 2007 12:59:59
reference us 31 Jul, 2007 12:59:58
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics