Generate a 2-dimensional array with random numbers
48 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hoque
el 24 de Sept. de 2018
Comentada: Hoque
el 24 de Sept. de 2018
I want to generate a 2-dimensional array with random numbers. * The first column would contain values from 5 to 1000 and the second column would contain values from 1 to 7.*
I generated a 2-dimensional array with random numbers, but not sure about the bold part of the above paragraph.
Y = 10
Z = 2
result = rand(Y,Z);
result(:,2:2:end) = result(:,2:2:end) .* result(:,2:2:end)
0 comentarios
Respuesta aceptada
Más respuestas (1)
Joel Meyer Espinoza
el 24 de Sept. de 2018
result(:,1)=randi([1 1000],1,10); result(:,2)=randi([1 7],1,10);
should work
it generates only int though the first parameters are the range of random numbers and the last two the size of the array
look here for more info
https://de.mathworks.com/help/matlab/math/random-integers.html
1 comentario
Joel Meyer Espinoza
el 24 de Sept. de 2018
make sure to hit enter after the first semicolon in the code
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!