How to get 10000 variable numbers between the range of 0 and 100?

2 visualizaciones (últimos 30 días)
i want a variable array of 10000 numbers from 0 to 100.
a = -5; b = 5; varx = a + (b-a).*rand(10000,1); varX = 10.^varx;
so i want this in the above format.
can you help me out?
  4 comentarios
Aniket Dutta
Aniket Dutta el 28 de Ag. de 2022
actually i want the values between 10^(-5) and 10^2.

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 27 de Ag. de 2022
Editada: Star Strider el 28 de Ag. de 2022
If you want the numers to be between and , use the logspace function, then use randperm to randomise them —
varx = logspace(-5, 5, 1E+5) % Generate Vector
varx = 1×100000
1.0e+05 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
varx = varx(randperm(numel(varx))) % Randomize It
varx = 1×100000
1.0e+05 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0000 0.0000 0.0000 0.0241 0.0000 0.0002 0.0000 0.9879 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0282 0.0000 0.0000 0.0000 0.0014 0.1385 0.0000 0.0000 0.0000
Check = [min(varx) max(varx)] % Check Result
Check = 1×2
1.0e+05 * 0.0000 1.0000
log10Check = log10(Check) % Verify
log10Check = 1×2
-5 5
EDIT — (28 Aug 2022 at 2:16)
actually i want the values between 10^(-5) and 10^2.’
varx = logspace(-5, 2, 1E+5) % Generate Vector
varx = 1×100000
1.0e+00 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
varx = varx(randperm(numel(varx))) % Randomize It
varx = 1×100000
12.2648 28.3893 0.0239 0.0008 4.9518 2.1702 0.0146 0.8131 0.2272 0.0000 0.2467 0.4178 5.3700 9.1466 28.9484 53.1701 0.0206 0.0001 0.0094 0.0249 2.5477 41.2094 1.6019 0.3318 41.3358 0.0008 66.8018 0.0000 0.7349 18.7881
Check = [min(varx) max(varx)] % Check Result
Check = 1×2
0.0000 100.0000
log10Check = log10(Check) % Verify
log10Check = 1×2
-5 2
.

Más respuestas (1)

Abderrahim. B
Abderrahim. B el 27 de Ag. de 2022
Movida: Image Analyst el 27 de Ag. de 2022
Try this --
varx = 100*rand(10000, 1) ;
min(varx)
ans = 0.0227
max(varx)
ans = 99.9844

Categorías

Más información sobre Elementary Math 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