필터 지우기
필터 지우기

creating a variable to use for grouping data

조회 수: 2 (최근 30일)
Rabeya
Rabeya 2012년 4월 20일
I want to create a variable (a column vector) with a specific length (8000), containing values 1 to 10 randomly assigned and with a specific average repetition of each number (say 800). How to do this?

채택된 답변

Walter Roberson
Walter Roberson 2012년 4월 20일
If the number of repetitions is to be exact:
t = repmat(1:10.', 800, 1);
t(randperm(length(t)))
If the repetitions need not be exact:
1 + floor(10 * rand(8000,1))
  댓글 수: 2
Rabeya
Rabeya 2012년 4월 20일
Very impressive!
Walter Roberson
Walter Roberson 2012년 4월 20일
Opps, I had an extra layer of repmat() on the first solution! I have edited.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by