How to generate a random matrix with a constraint or step range ?
Mostrar comentarios más antiguos
I want to generate a Nx4 random matrix. In this matrix, each column is considered having different range and step. The random values should be only from these steps.
For e.g. 1st column 0:0.1:1
2nd column > 0:1:10
3rd column > 2:0.5:8
4th column > 0:-1:-10
I want to generate a random matrix of N=5. I should get a matrix with above conditions. Like this
[0 5 3.5 -5 ;
0.8 8 7 -3
0.2 0 2.5 -7
0.6 8 6.5 0
0.9 3 7.5 -9]
The N value could go to any size. Repeated values are permissible. I tried some random functions like randperm, randsample etc but I am not able to produce like this. Randperm is not allowing to produce repeated values.
How could I generate it ? Could you help with a code sample ?
Respuesta aceptada
Más respuestas (1)
madhan ravi
el 23 de Abr. de 2020
Hint example:
x = 1:10;
N = 5;
x(randi(numel(x),1,N))
Categorías
Más información sobre Random Number Generation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!