Path: news.mathworks.com!not-for-mail
From: "Ci Griaal" <cigriaal@yahoo.com.au>
Newsgroups: comp.soft-sys.matlab
Subject: problem in generating random numbers after compiling the m file
Date: Thu, 15 Oct 2009 01:41:01 +0000 (UTC)
Organization: Monash Univ
Lines: 23
Message-ID: <hb5ujd$3i5$1@fred.mathworks.com>
Reply-To: "Ci Griaal" <cigriaal@yahoo.com.au>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1255570861 3653 172.30.248.37 (15 Oct 2009 01:41:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 Oct 2009 01:41:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1464997
Xref: news.mathworks.com comp.soft-sys.matlab:577389


hi all 
I am sampling random numbers from a normal distribution.
For example, if this is my simple code:

clear all;clc;
   %x1=Normal distribution N(mean=100,sd=5)
   n=25;
   x1 = ( randn(n,1) * 0.2 ) + 1.2;
%   
%% write
% Create a file
fidfile='x1.csv';
fid=fopen(fidfile,'w'); 
if (fid < 0)
    error('could not open file "x1.csv"');
end;
    fprintf(fid, '%f\n', x1);
    fprintf(fid, '\n'); 
fclose(fid);

This is running ok if i run it in Matlab environment (i.e. different set of values are generated every time I run the m file).
However, if I compile it and run the executable file (.exe) it generates the same set of random numbers every time I run it. 
Could anyone help me with this bug please?