Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

 Messages: [ Previous | Next ]
 Alan Weiss Posts: 1,430 Registered: 11/27/08
Re: Generate non integer number
Posted: Mar 13, 2013 11:10 AM

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

Date Subject Author
3/13/13 Curious
3/13/13 Alan Weiss
3/13/13 Curious
3/13/13 John D'Errico