generate random negative numbers
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
PK
el 26 de En. de 2013
Comentada: Edgar Andres Parra Rucaurte
el 27 de Oct. de 2016
I thank if some one can help in this, how can i generate a matrix of some size for ex 100x100 with in the range of [-0.01,0] and that too with decimal values contained in it like -0.001,-0.0056 like that and also for the ranges like [-60,-30] with decimal values like -58.254,-56.985 and only 3 decimal values after the point.
5 comentarios
Image Analyst
el 28 de En. de 2013
Sorry but you are wrong. Look at Greg's code below, which is the same as the help example I referred you to. You can certainly have "a" and "b" be negative numbers. Why do you think you can't? No one said they had to be positive.
Respuesta aceptada
Matt J
el 28 de En. de 2013
n=3; %number of decimal places
A = randi([-60,-30]*10^n,[100,100])/10^n;
3 comentarios
Más respuestas (1)
Greg Heath
el 26 de En. de 2013
x = a + (b-a)*rand(m,n);
Hope this helps.
Thank you for formally accepting my answer.
Greg
0 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices 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!