How can I distribute random points in some lines?

3 views (last 30 days)
The follow code is a poisson line process code.
I want to distibute the random points in the lines.
The point process is not specified. The point process is a unifrom random or a poisson point process.

Accepted Answer

KSSV
KSSV on 26 May 2020
%% Striaght line
L = rand(2,2) ;
P1 = L(1,:) ;
P2 = L(2,:) ;
% Get slope and y intercept
P = polyfit(L(:,1),L(:,2),1) ;
m = P(1) ;
c = P(2) ;
% Get random points
a = min(L(:,1)) ; b = max(L(:,1)) ;
N = 20 ;
x = (b-a)*rand(N,1)+a ;
y = m*x+c ;
figure
hold on
plot(L(:,1),L(:,2),'r')
hold on
plot(x,y,'*k')

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!