How can I distribute random points in some lines?

3 visualizaciones (últimos 30 días)
Han
Han el 26 de Mayo de 2020
Respondida: KSSV el 26 de Mayo de 2020
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.

Respuesta aceptada

KSSV
KSSV el 26 de Mayo de 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')

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by