function [x,y,z] = samplepoints_3dcyl(dist,nr_points,want_plot) % Randomly samples points in 3D space with a specified distribution. % Points lie in a cylinder of radius 1 and height 2, and probability % distribution can vary with theradius. % % Output: x-, y-, and z-coordinates for randomly sampled points in 3d % Input: dist = d(r) function handle, radius-dependent probability distribution in [0,1]. % nr_points = number of sample points % want_plot = 1 if you want the points plotted, 0 if not. k = 1; while k < nr_points+1 sample_pt = -1+2*rand(1,2); r = sqrt(sum(sample_pt.^2)); if rand