converting randit to randi

3 次查看(过去 30 天)
Amna Yousaf
Amna Yousaf 2019-6-11
回答: Dennis 2019-6-11
Randit it obsolete in newer versions of Matlab.
Can anyone guide me how to convert randit(1,1,9) to randi?
  1 个评论
Amna Yousaf
Amna Yousaf 2019-6-11
matrix(i,j)=randit(1,1,9). Please help me convert this to randi.

请先登录,再进行评论。

回答(2 个)

Walter Roberson
Walter Roberson 2019-6-11
https://www.mathworks.com/matlabcentral/answers/376258-what-does-x-randint-1-1-1-n#comment_522862

Dennis
Dennis 2019-6-11
matrix(i,j)=randi(9);
Instead of creating single random numbers in a loop maybe consider creating them as vector/matrix.
matrix=randi(9,10,10); %10x10 matrix with random numbers from 1-9
instead of
matrix=zeros(10,10);
for i=1:10
for j=1:10
matrix(i,j)=randi(9);
end
end

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by