Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!wns13feed!worldnet.att.net!199.45.49.37!cyclone1.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny05.POSTED!702e7bde!not-for-mail
From: James Tursa <aclassyguywithaknotac@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Pass structure to MATLAB
Message-ID: <lptri39i3da708skv77eju752ah8gf47c9@4ax.com>
References: <fgb6fp$8rt$1@fred.mathworks.com> <6p9li3t0t4mc554emmf7q74rd5iut85d5l@4ax.com> <fgef3h$qrv$1@fred.mathworks.com> <70jmi39c96s8iudh4r1ajrrto95r873uak@4ax.com> <fggni2$4sk$1@fred.mathworks.com> <gr9oi31ibje2d1608d9b53kef8a5kr8hvk@4ax.com> <fghqqr$5br$1@fred.mathworks.com> <8mbpi3t46ho1q6svitnckpscnj8o7n85oi@4ax.com> <fgk30j$jau$1@fred.mathworks.com>
X-Newsreader: Forte Agent 3.3/32.846
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 33
Date: Sun, 04 Nov 2007 17:02:22 GMT
NNTP-Posting-Host: 71.112.89.94
X-Complaints-To: abuse@verizon.net
X-Trace: trndny05 1194195742 71.112.89.94 (Sun, 04 Nov 2007 12:02:22 EST)
NNTP-Posting-Date: Sun, 04 Nov 2007 12:02:22 EST
Xref: news.mathworks.com comp.soft-sys.matlab:435999


On Sun, 4 Nov 2007 09:22:27 +0000 (UTC), "Faisal "
<faisal_mufti.nospam@yahoo.com> wrote:

>Hi James, one last thing if you can show me to pass to
>MATLAB these two structure values ( dist and ampl) as two
>output arguments and not as structures. ?
>Thanks,

1) Do you want to pass f.dist and f.ampl and u.dist and u.ampl?  i.e.,
do you want to pass all of them? Or just one of the versions, either
the double or the short?

2) Do you want to pass them in addition to the structures that are
already passed, or in place of the structures that are already passed?

Note that once the structures are in the MATLAB workspace, you can get
at the individual arrays easily. For example, using the current code I
just supplied:

>> [a b] = structput(1.0,'myfile');

then you can get at the individual arrays by typing a.dist, a.ampl,
b.dist, and b.ampl in the MATLAB workspace.  For example:

>> sum(a.dist)

Finally, note that I have assumed that an unsigned short in C was a
16-bit quantity. This isn't strictly guaranteed in C. You are really
only guaranteed that a short is at least 16 bits, but it could be
longer. To be more robust one would check sizeof(short) and then use
an mxUINT16_CLASS or an mxUINT32_CLASS accordingly.

James Tursa