Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: rand() using mexCallMATLAB
Date: Fri, 13 Sep 2013 18:50:07 +0000 (UTC)
Organization: Boeing Co
Lines: 18
Message-ID: <l0vmov$sbl$1@newscl01ah.mathworks.com>
References: <l0s63d$f2e$1@newscl01ah.mathworks.com> <l0s6ei$krk$1@newscl01ah.mathworks.com> <l0sbhm$m70$1@newscl01ah.mathworks.com> <l0sjvm$50f$1@newscl01ah.mathworks.com> <l0slcm$ki8$1@newscl01ah.mathworks.com> <l0u6g1$d3n$1@newscl01ah.mathworks.com> <l0u80m$8qo$1@newscl01ah.mathworks.com> <l0u9sm$ap5$1@newscl01ah.mathworks.com> <l0ubdf$6o4$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: rubyext-00-ls.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1379098207 29045 172.20.102.176 (13 Sep 2013 18:50:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 13 Sep 2013 18:50:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:802393

"Hariprasad" wrote in message <l0ubdf$6o4$1@newscl01ah.mathworks.com>...
> 
> > > > mexCallMATLAB(1,lhs[0],2,rhs,"rand"); 
> 
> Could this have been the point of error.. "lhs[0]"  ?
> Because in my other loop for randoms2 I had put mexCallMATLAB(1,lhs2[0],2,rhs2,"rand");
> I got randoms2 as Zero. Then I changed it to 
> mexCallMATLAB(1,lhs2,2,rhs2,"rand"); and compiled again, got it fine!!!
> I'm not sure but that's how it worked for me.

The signature for mexCallMATLAB listed in the documentation is as follows:

int mexCallMATLAB(int nlhs, mxArray *plhs[], int nrhs,
  mxArray *prhs[], const char *functionName);

The expected type for the 2nd argument is thus mxArray **. But the type of lhs[0] is just mxArray *. That difference, in and of itself, should tell you that the use of lhs[0] for this argument is wrong. That is why you needed to drop the [0] for this argument to work properly.

James Tursa