How to generate non repeating random numbers

조회 수: 3 (최근 30일)
Deepa AS
Deepa AS 2015년 8월 9일
댓글: Deepa AS 2015년 8월 9일
Hi, I have a matrix of size 270x360 ,what i need to do is generate any random location in that matrix such that all the locations of that matrix are generated at least for once.Is that possible.If so can anybody please help me with it? Thank you, Deepa

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 8월 9일
편집: Azzi Abdelmalek 2015년 8월 9일
A=zeros(270,360)
The locations of the matrix A are 1:270*360 (using linear indexing)
n=270*360
random_location=randperm(n)
If you want subscript indices ii and jj use ind2sub function
[ii,jj]=ind2sub(size(A),random_location)
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2015년 8월 9일
Have you read the answer?
Deepa AS
Deepa AS 2015년 8월 9일
I just noticed ,thank you sir.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by