How can I distribute random points in some lines?

3 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

KSSV
KSSV il 26 Mag 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')

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by