Function to be used for calculating number of points(randomly generated) inside the rectangular area
조회 수: 2 (최근 30일)
이전 댓글 표시
Number of points inside the rectangular area for randomly generated numbers...
댓글 수: 1
David Hill
2022년 3월 8일
I have no idea what you are asking. Please explain what you are trying to do and provide some code.
답변 (1개)
David Hill
2022년 3월 8일
편집: David Hill
2022년 3월 8일
I assume something like this: (other dimension does not matter)
r=1000*rand(1,100000);%generate 100000 rand numbers between 0 and 1000
p=[563,565.7,616.5,619.2,670,672.7];
for k=1:length(p)
n(k)=nnz(r>p(k)&r<=p(k)+.8);%provides the number of points in each rectangle
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Monte-Carlo에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!