How to make a 2D contour Map

8 vues (au cours des 30 derniers jours)
Darrian Low
Darrian Low le 8 Mar 2019
Commenté : Darrian Low le 14 Mar 2019
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.

Réponses (1)

Astha Singh
Astha Singh le 14 Mar 2019
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 commentaire
Darrian Low
Darrian Low le 14 Mar 2019
Thank you very much for your help. By any chance would you know how to transform this plot into a 2D contour map?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by