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!