Obtaining width of section along a line in contour plot

1 回表示 (過去 30 日間)
Saeid
Saeid 2017 年 8 月 11 日
コメント済み: KSSV 2017 年 8 月 11 日
I use ginput to select a hanful of points on a contour plot, created from xyz data. Now I want to create a vector that e.g. starts at the first point selected and ends at the second point and covers all the points on the route. It would be easy if the selection were always a diagonal matrix but in non-diagonal cases the line usually cuts through two adjacent elements of a row (or column). As stated above I can click on two points of a contour plot to obtain the indices using ginput and the corresponding z values. What I need now is the the maximum z value occurring along the red line and the width of the area under the selected line (red line in picture below).

回答 (1 件)

KSSV
KSSV 2017 年 8 月 11 日
As you have (x,y) of the red line in hand, use interp2 to get the corresponding z values....to get area use trapz.
  2 件のコメント
Saeid
Saeid 2017 年 8 月 11 日
Thanks KSSV, but this was not what I exactly wanted. I don't need an approximation (or interpolation) of what lies under the red line, but the exact existing values of the array that is the source of my plot.
KSSV
KSSV 2017 年 8 月 11 日
If your point lie's exactly on the given point..you will get what you want...if it is deviated, it will be interpolated....still..if you are particular....you can use knnsearch to get nearest neighbour and extract that pixel.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by