obtaining values major than 10e-7

12 次查看(过去 30 天)
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 个评论
Jan
Jan 2012-9-15
编辑:Jan 2012-9-15
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)

请先登录,再进行评论。

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2012-9-15
  3 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2012-9-15
编辑:Azzi Abdelmalek 2012-9-15
x = 2*rand*10e-7
%you will have randomly > or <
Salvatore Mazzarino
yes...now it work...thanks so much Azzi

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Signal Processing Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by