Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: generating random numbers
Date: Thu, 2 Feb 2012 20:23:16 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 7
Message-ID: <jgerbj$og3$1@newscl01ah.mathworks.com>
References: <jgalvu$kkb$1@newscl01ah.mathworks.com> <jgc592$ofk$1@newscl01ah.mathworks.com> <jgdbsm$l18$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1328214196 25091 172.30.248.45 (2 Feb 2012 20:23:16 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 2 Feb 2012 20:23:16 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:756554

"yugandhar ch" <yug_0203@rediffmail.com> wrote in message <jgdbsm$l18$1@newscl01ah.mathworks.com>...
> thanks Mr.Roger for your suggestion. In case of triangular dist ,the pdf  is in intervals
> then how to write cdf in a single function.I would be grateful to you if send the code
- - - - - - - - -
  It is quite possible to write a single function in which the form of the function depends on some condition.  In your case the one condition is whether the 'rand' value is less than the (c-a)/(b-a) value referred to in that Wikipedia article.  With m-file functions, just use an if-else construction and with anonymous functions a logical inequality quantity (e.g., "@(x) (x>=0)*exp(x)+(x<0)*(sin(x)+1)" ).

Roger Stafford