Generate random 3D coordinates in a cylinder

3 vues (au cours des 30 derniers jours)
Lucy
Lucy le 21 Sep 2015
Modifié(e) : Image Analyst le 18 Fév 2019
I want to generate a set of 1000 3D points (x,y,z) which are located inside a cylinder of radius r and centre axis from [x1,y1,z1] to [x2,y2,z2]. Any ideas?

Réponse acceptée

Image Analyst
Image Analyst le 21 Sep 2015
Roger Stafford's code in the FAQ for getting random points in a circle will be easy to modify. http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_set_of_random_locations_within_a_circle.3F
Simply add a random variable for the height (Z) direction.
  1 commentaire
Lucy
Lucy le 21 Sep 2015
Thanks for your response

Connectez-vous pour commenter.

Plus de réponses (1)

Vu Ngoc Quang
Vu Ngoc Quang le 18 Fév 2019
Everyone can help me
Write Matlap code that generates 3-D coordinates of 50 points (evenly distributed). These points have the same length of 26371Km. This is the first time that I learn Matlap. So please help?
  1 commentaire
Image Analyst
Image Analyst le 18 Fév 2019
Modifié(e) : Image Analyst le 18 Fév 2019
What does evenly distributed mean to you? Random according to a uniform distribution (like raindrops on the ground), or in a regular grid like a rectangular grid or a honeycomb grid?
For a grid (of some kind) you could do
array3d = zeros(rows, columns, slices);
indexes = round(linspace(1, numel(array3d), 50));
array3d(indexes) = 1;

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by