From: Kimonas Fountoulakis on
Hi

I have a matlab function, "getData" which has a random generator in it. Whenever I call the getData function like this:

[A,b,xs,xsn] = getData(2,4,1,0,1,0,0,200) <- the last parameter is the seed

if I have a the same seed at every call I get the same result, which is normal.
But when I call getData through a mex file, with exactly the same parameters as above I get different results, plus even if I call my mex file many times with fixed parameters, I get everytime different results. It behaves like there is no seed parameter (or every time the seed is different).

Any ideas??

Thanks in advance
From: Steven Lord on

"Kimonas Fountoulakis" <kfoynt(a)hotmail.com> wrote in message
news:huupuk$p8o$1(a)fred.mathworks.com...
> Hi
> I have a matlab function, "getData" which has a random generator in it.
> Whenever I call the getData function like this:
>
> [A,b,xs,xsn] = getData(2,4,1,0,1,0,0,200) <- the last parameter is the
> seed
>
> if I have a the same seed at every call I get the same result, which is
> normal.
> But when I call getData through a mex file, with exactly the same
> parameters as above I get different results, plus even if I call my mex
> file many times with fixed parameters, I get everytime different results.
> It behaves like there is no seed parameter (or every time the seed is
> different).
>
> Any ideas??

Yes -- this problem is going to be impossible to debug without seeing a
simplified (aka short) version of getData and your MEX-file with which you
can reproduce the problem.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


From: Jan Simon on
Dear Kimonas!

> I have a matlab function, "getData" which has a random generator in it. Whenever I call the getData function like this:
>
> [A,b,xs,xsn] = getData(2,4,1,0,1,0,0,200) <- the last parameter is the seed
>
> if I have a the same seed at every call I get the same result, which is normal.
> But when I call getData through a mex file, with exactly the same parameters as above I get different results, plus even if I call my mex file many times with fixed parameters, I get everytime different results. It behaves like there is no seed parameter (or every time the seed is different).

Either your Mex calls getData without a 8th argument, of the 8th argument is random, e.g. if you use the address of a variable instead of the value.

But of course, an answer could be much more detailed, if you'd show the corresponding lines of code...

Jan
From: Patrick on
I would suggest doing a mexPrintf to verify that you read in your parameters correctly.

"Kimonas Fountoulakis" <kfoynt(a)hotmail.com> wrote in message <huupuk$p8o$1(a)fred.mathworks.com>...
> Hi
>
> I have a matlab function, "getData" which has a random generator in it. Whenever I call the getData function like this:
>
> [A,b,xs,xsn] = getData(2,4,1,0,1,0,0,200) <- the last parameter is the seed
>
> if I have a the same seed at every call I get the same result, which is normal.
> But when I call getData through a mex file, with exactly the same parameters as above I get different results, plus even if I call my mex file many times with fixed parameters, I get everytime different results. It behaves like there is no seed parameter (or every time the seed is different).
>
> Any ideas??
>
> Thanks in advance