How do i get decimal values using randi?
    조회 수: 3 (최근 30일)
  
       이전 댓글 표시
    
.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
채택된 답변
  Adam Danz
    
      
 2020년 2월 5일
        
      편집: Adam Danz
    
      
 2020년 2월 5일
  
      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
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

