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$>
References: <l0s63d$f2e$> <l0s6ei$krk$> <l0sbhm$m70$> <l0sjvm$50f$> <l0slcm$ki8$> <l0u6g1$d3n$> <l0u80m$8qo$> <l0u9sm$ap5$> <l0ubdf$6o4$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1379098207 29045 (13 Sep 2013 18:50:07 GMT)
NNTP-Posting-Date: Fri, 13 Sep 2013 18:50:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: comp.soft-sys.matlab:802393

"Hariprasad" wrote in message <l0ubdf$6o4$>...
> > > > 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