How do i get decimal values using randi?
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Jose Grimaldo
 el 5 de Feb. de 2020
  
.png)
Im supposed to create a 3x4 matrix with random decimal value from -10 to 20. Im not sure how to get decimal values.
0 comentarios
Respuesta aceptada
  Adam Danz
    
      
 el 5 de Feb. de 2020
        
      Editada: Adam Danz
    
      
 el 5 de Feb. de 2020
  
      randi() will only return integers.  Instead, use rand() which will prouduce random values between 0 and 1; then scale and shift the results to the defined bounds. 
arraySize = [3,4]; 
bounds = [-10,20]; 
x = rand(arraySize)*range(bounds)+bounds(1);
0 comentarios
Más respuestas (0)
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!

