How can I distribute random points in some lines?

조회 수: 1 (최근 30일)
Han
Han 2020년 5월 26일
답변: KSSV 2020년 5월 26일
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.

채택된 답변

KSSV
KSSV 2020년 5월 26일
%% 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')

추가 답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by