Finding normals to contours on contour plot
조회 수: 12 (최근 30일)
이전 댓글 표시
Is there a good way to find a set of curves that are normal to the contours on a contour plot?
What I have is a set of data that I have used meshgrid and contour to generate a contour plot, however what I really want is a set of curves that are normal to the contours shown in the plot. I am not sure if there is a straightforward way to get that.
thanks Greg
댓글 수: 0
채택된 답변
Kelly Kearney
2017년 4월 20일
Take a look at the various streamline functions ( stream2, streamline, etc). Depending on your surface, you may need to do some analysis to figure out the best starting points to get even coverage (in the following example, I just chose random points):
[X,Y] = meshgrid(-2:.2:2);
Z = X.*exp(-X.^2 - Y.^2);
[DX,DY] = gradient(Z,.2,.2);
nline = 100;
xstart = rand(nline,1)*4 - 2;
ystart = rand(nline,1)*4 - 2;
xy = stream2(X,Y,DX,DY,xstart, ystart)
figure
contour(X,Y,Z)
hold on
streamline(xy);
댓글 수: 0
추가 답변 (1개)
Andrew Newell
2017년 4월 20일
You want curves to follow the gradients. It's easy enough to represent the gradient using a quiver plot, but if you want to put lines through those arrows, you'll probably have to set up and solve an ODE for each starting point. That would certainly be doable if you had a function that generated the data, but I don't know how you'd do that for a data set.
댓글 수: 0
참고 항목
카테고리
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!