Plotting random points in matlab
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone, I have this figure which is shown below. I am getting a certain pattern of points every time i run my simulation. I mean, although the points are different every time but there is always some pattern in these points. Why is this, i don't know.
댓글 수: 6
Star Strider
2014년 6월 18일
That is because xx and yy are scaled, so that the radius component is always on the interval (0,r) and the quadrant is defined by the sign of the sin and cos (respectively) of different random numbers, this time on the interval (0,2*pi), so those parts of the calculation are defined on the interval (-1,1).
The end result is that xx and yy are each independently defined on the same interval for both the radius and angle compoents, but are different because the values returned by rand are different. Here, it looks as though they will always end up on an angle that is some odd integer multiple of (pi/4) radians, with varying radii.
Those explain posxy(:,1:2). I don’t understand posxy(:3).
채택된 답변
Star Strider
2014년 6월 18일
Computer-generated random numbers aren’t really ‘random’ in the mathematical sense of ‘randomness’ because they depend on deterministic algorithms and finite word lengths to compute them. These also depend on where the random number generator starts (the ‘seed’ number). The term used to describe numbers generated by these algorithms is ‘pseudorandom’ for that reason.
MathWorks explains it better than I can, because they wrote the algorithms. See Random Numbers in MATLAB and Why Do Random Numbers Repeat After Startup? for details.
댓글 수: 2
Star Strider
2014년 6월 18일
Here, the sign function forces the angle the radii are plotted against to always be an odd integer multiple of (pi/4) radians (45°).
Removing the sign function allows the angle to be defined randomly on the interval (0,2*pi).
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!