Contour or mesh plot of irregular-spaced data

9 ビュー (過去 30 日間)
Vivek Gupta
Vivek Gupta 2019 年 10 月 24 日
回答済み: darova 2019 年 10 月 25 日
Hello all,
I have data in the form of 3 vectors (x, y, z). The x and y vectors definitely contain duplicate numbers within each vector, but there are no duplicate x,y pairs. All x,y values are in incremements of 10, but for a given domain, not all the points are available. Example data:
For 0<= x,y <= 20
x = [0, 0, 0, 10, 10, 20, 20];
y = [0, 10, 20, 0, 20, 0, 10];
z = [20, 10, 40, 50, 10, 30];
Is there an easy way to plot the z values for given x,y coordinates? If not, two others other things I could try:
1) I know the mesh and surf functions can be used to plot irregular spaced data (here), but they require matrices as inputs. Is there an easy way to convert the vector data I have into matrix form so I can use the mesh function?
2) I could linearly interpolate the z values for the x,y pairs that are missing, but this seems like a last resort.

回答 (1 件)

darova
darova 2019 年 10 月 25 日
Use griddata to convert your vectors into matrices

カテゴリ

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