Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Distance randomly generated with density function
Date: Sat, 19 Nov 2011 13:57:10 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 8
Message-ID: <ja8cjm$11f$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1321711030 1071 172.30.248.35 (19 Nov 2011 13:57:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 19 Nov 2011 13:57:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3189466
Xref: news.mathworks.com comp.soft-sys.matlab:749846

Hello everyone, 

I have the density function f(d)=2d, where d is the distance of a user and 0<=d=<1 (kilometers). My system has 64 users and i want the distance d of a user to be generated randomly with the above density function. I have programmed a code but i believe it's not responding in my needs. Can someone explain me how can i simulate this ? My code is following.

PROB=[.01 .03 .05 .07 .09 .11 .13 .15 .17 .19] ;
temporary = randp(PROB,N);
d=zeros(1,N);
d=0.1.*temporary(1,:);