フィルターのクリア

How to make a 2D contour Map

3 ビュー (過去 30 日間)
Darrian Low
Darrian Low 2019 年 3 月 8 日
コメント済み: Darrian Low 2019 年 3 月 14 日
Hello,
I am given a text file with three columns of various lengths. The first column is an 'x' value, the second column is a 'y' value, the third column is a 'z' (heights) value.
My goal is to make a 2D contour map using these three columns of data. The data I have looks a little organised, but they're mostly scattered. I have attached a picture on what it sort of looks like.
MATLABHELP.png
Each of those dots have a 'z' (height) value. Below is a sample of data I could have.
X Y Z
10 10 07
10 20 10
20 10 09
20 20 13
13 13 08
15 16 10
The goal is to use those six points for a 2D contour map. Bare in mind that I cannot hard code this. Since next time, I could be given 10 points to work with, or 20, or 50, or even a hundred.
Cheers for your help! I look forward to seeing your solutions.

回答 (1 件)

Astha Singh
Astha Singh 2019 年 3 月 14 日
If you want to obtain the above plot, you can use the scatter function to plot marker points at the corresponding x and y co-ordinates. Also, if you want to add text along with the marker points, you can use the text function.
Please see the below attached code for reference:
x = [10,10,20,20,13,15];
y = [10,20,10,20,13,16];
z = [7,10,9,13,8,10];
Z = num2str(z');
Zf = cellstr(Z);
scatter(x,y,'filled')
text(x+0.1, y+0.1, Zf)
Depending in the format of the input text file, the values of x, y and z can be read, using one the different methods listed in the link below:
  1 件のコメント
Darrian Low
Darrian Low 2019 年 3 月 14 日
Thank you very much for your help. By any chance would you know how to transform this plot into a 2D contour map?

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

カテゴリ

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