Embedded code for Randi function.it generates 625 arrays to some values, I want to know why it is generated 625 arrays of random values in initial function
조회 수: 2 (최근 30일)
이전 댓글 표시
y = randi([0, 11],uint32)
댓글 수: 1
Ganesh
2024년 5월 30일
I assume you mean that it creates an array with 625 values. I also assume that you do not intend to use the function "uint32()".
There is likely a variable in workspace with the name uint32 with a value of 25.
When you provide a single size, here uint32, to "randi()", it creates a matrix of size uint32*uint32, hence you get an array with 625 values. Reading the documentation related to the function "randi()" thoroughly will certainly help.
답변 (1개)
Manikanta Aditya
2024년 5월 30일
편집: Manikanta Aditya
2024년 5월 30일
The randi function in MATLAB generates uniformly distributed random integers in a specified interval. The syntax you’ve used, randi([0, 11],uint32), is not correct as the second argument to randi should be the size of the array you want to generate.
If you want to generate a 625-element array of random integers between 0 and 11, you should use:
y = randi([0, 11], [1, 625]);
disp(y);
This will create a 1x625 matrix y with each element being a random integer between 0 and 11.
If you’re seeing 625 arrays being generated, it’s likely due to a loop or other repeated call to randi in your code and also it might be due to a loop or function call not shown in the snippet you provided. Ensure that the context of the function call is appropriate and not wrapped in unnecessary loops unless required by your application.
I think this clarifies!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!