Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Generate non integer number
Replies: 4   Last Post: Mar 13, 2013 1:39 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Curious

Posts: 2,007
Registered: 12/6/04
Re: Generate non integer number
Posted: Mar 13, 2013 11:52 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Alan_Weiss <aweiss@mathworks.com> wrote in message <khq4sg$e5a$1@newscl01ah.mathworks.com>...
> On 3/13/2013 10:05 AM, max200790 wrote:
> > Hi,
> > I would know how I can generate a non integer number with the
> > function randi without utilizing a division or multiplication.
> > Maybe we know another function which only specifying the interval give
> > the random value as:
> >
> > Amin=0
> > Amax=5
> > A=......([Amin,Amax])
> >
> >
> > A=1.954
> >
> > Thanks
> >

>
> A = Amin + (Amax - Amin)*rand
>
> If Amin and Amax are vectors or matrices,
>
> A = Amin + rand(size(Amin)).*(Amax - Amin)
>
> Alan Weiss
> MATLAB mathematical toolbox documentation


The above uses the function rand - NOT randi.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.