Varying Random Number Generator between a Range

1 visualización (últimos 30 días)
Chris Dan
Chris Dan el 3 de Sept. de 2020
Comentada: Chris Dan el 3 de Sept. de 2020
Hello,
I am trying to vary a random number generator between a range of vectors, this is my code
ub =[1;1;2;2;2;2;2;2;2;2];
lb =[0.95;0.96;1.88;1.88;1.85;1.85;1.75;1.75;1.65;1.58]
Y = lb + (ub-lb).*rand(10,1)
The result I am getting is a 10x4 double matrix, I want a 10x1 vector.
What changes I should make?

Respuestas (1)

KSSV
KSSV el 3 de Sept. de 2020
lb = [750,150,8,8];
ub = [850,250,15,15];
%
id1 = randperm(length(lb),1) ; % select 1 lb randomly
id2 = randperm(length(ub),1) ; % select 1 ub randomly
Y = lb(id1) + (ub(id2)-lb(id1))*rand(10,1)
  6 comentarios
Bruno Luong
Bruno Luong el 3 de Sept. de 2020
Great so now what is the size of Y?
You just answer your own question I think.
Chris Dan
Chris Dan el 3 de Sept. de 2020
yeap, I guess :)

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by