obtaining values major than 10e-7

13 visualizaciones (últimos 30 días)
Salvatore Mazzarino
Salvatore Mazzarino el 15 de Sept. de 2012
I use rand function to generate values
x = rand;
after that I compared generated values to
10e-7
if x > 10e-7
do something
end
unfortunately rand generates values always bigger 10e-7. How can I generate values that are less than 10e-7 using rand function?
  1 comentario
Jan
Jan el 15 de Sept. de 2012
Editada: Jan el 15 de Sept. de 2012
Do you mean 10e-7, which is 1e-6? The reply of RAND is not always greater than 1e6, but the chance to get a smaller value is 1 to 1e6. Try:
x = rand(1,1e7);
sum(x < 1e-6)

Iniciar sesión para comentar.

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 15 de Sept. de 2012
x = rand*10e-7
  3 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 15 de Sept. de 2012
Editada: Azzi Abdelmalek el 15 de Sept. de 2012
x = 2*rand*10e-7
%you will have randomly > or <
Salvatore Mazzarino
Salvatore Mazzarino el 15 de Sept. de 2012
yes...now it work...thanks so much Azzi

Iniciar sesión para comentar.

Categorías

Más información sobre Signal Processing Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by