MATLAB Answers

converting randit to randi

7 views (last 30 days)
Amna Yousaf
Amna Yousaf on 11 Jun 2019
Answered: Dennis on 11 Jun 2019
Randit it obsolete in newer versions of Matlab.
Can anyone guide me how to convert randit(1,1,9) to randi?

  1 Comment

Amna Yousaf
Amna Yousaf on 11 Jun 2019
matrix(i,j)=randit(1,1,9). Please help me convert this to randi.

Sign in to comment.

Answers (2)

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

  0 Comments

Sign in to comment.


Dennis
Dennis on 11 Jun 2019
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

  0 Comments

Sign in to comment.

Sign in to answer this question.

Products


Release

R2018a

Translated by