필터 지우기
필터 지우기

Array - Determine parameters (least number picked etc)

조회 수: 1 (최근 30일)
Rich
Rich 2013년 7월 23일
Hi All, I have a couple questions for arrays I was hoping I could get help with.
I am making an array that is 2500,1 and the numbers are randomly generated
1) How do I determine the number that was drawn the least?
2) Determine how many times a range of numbers was drawn?
Thanks so much ahead of time
  댓글 수: 1
Rich
Rich 2013년 7월 23일
편집: Rich 2013년 7월 23일
Thanks for the reply guys, what I ended up doing was generating another array based off the results, basically a 52,1 array that has the number of times each number was drawn
Using MAX, and MIN works great for that but I am having trouble with the range part of it.
What I tried to do was range=sum(results(lowrange:highrange))
but I get an error, any suggestions for that?
The error is that the matrix is too large
Thanks

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

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2013년 7월 23일
편집: Andrei Bobrov 2013년 7월 23일
Use functions:
1. min;
2. unique and histc.

David Sanchez
David Sanchez 2013년 7월 23일
%Generate integer values from the uniform distribution on the set 1:10:
r = randi(10,2500,1); % 2500 randomly distributed numbers on the range 1:10
x=1:10;
n = hist(r,x); % histogram with value distribution
[minimum_apearance index]= min(n); % index will give the numbe appearing the least

카테고리

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