フィルターのクリア

How to get the Z-contour values related to scatter positions?

2 ビュー (過去 30 日間)
Philippe Corner
Philippe Corner 2020 年 11 月 24 日
コメント済み: Philippe Corner 2020 年 12 月 2 日
The matrix M contains X, Y, Z values related to 1st, 2nd and 3rd columns respectively. It is plotted on a contour using the follwing code
load('M')
load('ref')
X=M(:,1);
Y=M(:,2);
Z=M(:,3);
[xq,yq]=meshgrid(linspace(min(X),max(X),100),linspace(min(Y),max(Y),100));
zq=griddata(X,Y,Z,xq(:),yq(:),'cubic');
[c,h]=contourf(xq,yq,reshape(zq,100,100),'levelstep',120);
hold on
scatter(ref(:,1),ref(:,2),'filled','k') % the dots where I want to get the contour value
ref.mat contains X, Y positions that suporpose the contour from M. I would like to get the Z information associated to exactly the X,Y positions of re.mat vector only for the areas where the dots overlaps the contour as you can see in the figure:
The final result can be a matrix M2, such as 1st column (X position over the contour); 2nd column (Y position over the contour) and 3rd column the extracted Z values related to M matrix contour.

採用された回答

KSSV
KSSV 2020 年 11 月 24 日
Read about ScatteredInterpolant.
  1 件のコメント
Philippe Corner
Philippe Corner 2020 年 12 月 2 日
Hello KSSV, I solved it using the function you suggested. Thank you.
Please take a look on this loop i would like to make to eliminate some part of my data: https://www.mathworks.com/matlabcentral/answers/671943-how-create-a-matrix-that-matches-a-condition-in-comparison-with-other-matrix?s_tid=srchtitle

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by