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$>
References: <jgalvu$kkb$> <jgc592$ofk$> <jgdbsm$l18$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1328214196 25091 (2 Feb 2012 20:23:16 GMT)
NNTP-Posting-Date: Thu, 2 Feb 2012 20:23:16 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:756554

"yugandhar ch" <> wrote in message <jgdbsm$l18$>...
> 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