Borrar filtros
Borrar filtros

creata random plot

3 visualizaciones (últimos 30 días)
Kugen Raj
Kugen Raj el 19 de Mzo. de 2012
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?

Respuestas (1)

Wayne King
Wayne King el 19 de Mzo. de 2012
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 comentarios
Wayne King
Wayne King el 19 de Mzo. de 2012
what do you mean the reference node of (0,0)? All the vectors are plotted from (0,0)
Kugen Raj
Kugen Raj el 19 de Mzo. de 2012
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.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by