Obtain z-values in contour plot using x,y coordinates of a point of interest
조회 수: 12 (최근 30일)
이전 댓글 표시
Dear Matlab community,
For a project I would like to know the Z-values along a line in the contour plot. The line consists of multiple points, x,y coordinates, at which I would like to read the Z-value from the contour plot. In practice it maybe means that some points require an interpolation, because not all x,y-values are present as input.
Is there a function available which can be used to obtain the z-value for a certain x,y-coordinate in a contour plot? If not, do you maybe have an idea how I could obtain these values?
Regards, Johan
댓글 수: 0
답변 (1개)
David K.
2019년 7월 16일
You could potentially use the interp2 function. If you used
Contour(X,Y,Z);
you could then use
interp2(X,Y,Z,Xq,Yq);
to obtain the Z values at the new Xq and Yq.
Depending on your original data set this may not work if your X or Y are not monotonically increasing.
You may also have some issue with column and row vectors in interp2, if they are not matrices, X's need to be row vectors and Y's need to be column vectors.
Hope this helps.
댓글 수: 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!