creata random plot

i need to create a random plot inside a circle. i used the r = a + (b-a).*rand(100,1), but it is not working as i only get the positive values. i need to make random plot from a reference node of x,y(0,0) until 10 radius. how can i do this?

답변 (1개)

Wayne King
Wayne King 2012년 3월 19일

0 개 추천

Do you want the points to all have radius 10? or can they have random length up to 10?
If it's the former:
phaseang = -pi+ 2*pi*rand(100,1);
z = 10*exp(1j*phaseang);
compass(real(z),imag(z));
%or
quiver(zeros(100,1),zeros(100,1),real(z),imag(z));
If the latter:
magz = 1e-5+(10-1e-5)*rand(100,1);
%or just magz = 10*rand(100,1);
phaseang = -pi+ 2*pi*rand(100,1);
z = magz.*exp(1j*phaseang);
quiver(zeros(100,1),zeros(100,1),real(z),imag(z));

댓글 수: 7

Kugen Raj
Kugen Raj 2012년 3월 19일
i want the points to have random length up to 10.
Wayne King
Wayne King 2012년 3월 19일
then use my second example
Kugen Raj
Kugen Raj 2012년 3월 19일
can i know what each command does. do you have any doc.
Wayne King
Wayne King 2012년 3월 19일
It's all in the MATLAB doc
Kugen Raj
Kugen Raj 2012년 3월 19일
i have one problem with this plotting. the plot is beyond the reference node of x,y(0,0).
Wayne King
Wayne King 2012년 3월 19일
what do you mean the reference node of (0,0)? All the vectors are plotted from (0,0)
Kugen Raj
Kugen Raj 2012년 3월 19일
i want my random points to be around node of (0,0) and up to length of 10. The produced points are not around the node of(0,0) but p to length of 10.

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

태그

아직 태그를 입력하지 않았습니다.

질문:

2012년 3월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by