How can I create a fine contour from set of points?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
I am creating different contours using (x,y) coordinate of points.
Say if i want to create a triangle I would use
x1=(0,0)
x2=(8,-4)
x3=(8,4)
x4=(0,0)
giving me this contour:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196668/image.jpeg)
But, i need more points on this contour, especially near the edges:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196669/image.jpeg)
which for various contours i calculate manually.
Now I want to automate this, and add those points near the edges with a given length.
Should I write a for loop, calculate the distance between neighboring points, divide by given length, and use to get the additional points and repeat?
Or is there a better way?
댓글 수: 0
채택된 답변
KSSV
2018년 9월 27일
x1=[0,0] ;
x2=[8,-4] ;
x3=[8,4] ;
x4=[0,0] ;
P = [x1 ; x2 ; x3 ; x4] ;
plot(P(:,1),P(:,2)) ;
N = 10 ;
t = linspace(0,1,N)' ;
L = cell(3,1) ;
for i = 1:3
L{i} = [P(i,1)+(P(i+1,1)-P(i,1))*t P(i,2)+(P(i+1,2)-P(i,2))*t] ;
end
L = cell2mat(L) ;
hold on
plot(L(:,1),L(:,2),'.r')
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!