how can i generate 4 nodes lie in a straight line, and how to find midpoint between first and last point. Thank you
조회 수: 2 (최근 30일)
이전 댓글 표시
how can i generate 4 nodes lie in a straight line, and how to find midpoint between first and last point. Thank you
댓글 수: 0
답변 (1개)
KSSV
2020년 10월 21일
You need any two points to get a striaght line. So I am selecting two random points to plot a line here.
% Random points to plot a line
P0 = rand(1,2) ;
P1 = rand(1,2) ;
x = [P0(1,1) P1(1,1)] ; % x coordinates
y = [P0(1,2) P1(1,2)] ; % y coordinates
% distance
d = sqrt(sum((P0-P1).^2)) ;
% divide into fpur equal parts
xi = linspace(P0(1),P1(1),4) ;
yi = interp1(x,y,xi) ;
% Mid point
M = (P0+P1)/2 ;
% plot
plot(x,y,'b')
hold on
plot(xi,yi,'-*r')
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!