how to generate numbers randomly

9 visualizaciones (últimos 30 días)
lucky yeggina
lucky yeggina el 6 de Mzo. de 2011
i'm currently working on a project "Generation of varaiable SLL & variable beamwidth beams using GENETIC ALGORITHM using amplitude variation." here i need to generate amplitudes(excitations ) randomly. so., hw can i generate amplitudes randomly.
thanq in advance....

Respuesta aceptada

Andrew Newell
Andrew Newell el 6 de Mzo. de 2011
You can use rand to generate random numbers.
  1 comentario
lucky yeggina
lucky yeggina el 8 de Mzo. de 2011
thnq., i did use rand(n) instead of rand.,
thanq so much

Iniciar sesión para comentar.

Más respuestas (3)

lucky yeggina
lucky yeggina el 6 de Mzo. de 2011
aah well but., rand generates array of numbers like rand(n) gives nxn matrix of elements btw o and 1 but MATLAB doesnt access array elemnts wid 0 ri8?
  1 comentario
Andrew Newell
Andrew Newell el 6 de Mzo. de 2011
This should be a comment, not an Answer. What do you mean by "access"? MATLAB does lots of things with zeros.

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 6 de Mzo. de 2011
Are you trying to generate a random index in to an vector? If so, then
VectorIndices = ceil(length(TheVector) * rand(1,n));

Matt Tearle
Matt Tearle el 6 de Mzo. de 2011
If you want indices, use randi to generate integers from 1 to n
idx = randi(length(x),7,1)
random7 = x(idx)
This samples with replacement. To shuffle an array use randperm
idx = randperm(length(x));
shufflex = x(idx);

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by