Contour plot of XYZ data

Hi,
I have attached X(:,1)Y(:,2)Z(:,3) data from which I would like to create a 2D contour plot. Thank you in advance for any help.

Réponses (1)

Ameer Hamza
Ameer Hamza le 30 Déc 2020
Modifié(e) : Ameer Hamza le 30 Déc 2020

0 votes

Try this
x = hfm(:,1);
y = hfm(:,2);
z = hfm(:,3);
xg = linspace(min(x),max(x));
yg = linspace(min(y),max(y));
[Xg, Yg] = meshgrid(xg, yg);
Zg = griddata(x, y, z, Xg, Yg);
contour(Xg, Yg, Zg)
or following if you want to extrapolate the data too
x = hfm(:,1);
y = hfm(:,2);
z = hfm(:,3);
xg = linspace(min(x),max(x));
yg = linspace(min(y),max(y));
[Xg, Yg] = meshgrid(xg, yg);
mdl = scatteredInterpolant(x, y, z);
Zg = mdl(Xg, Yg);
contour(Xg, Yg, Zg)

2 commentaires

LukeJes
LukeJes le 30 Déc 2020
Thank you Ameer!
Ameer Hamza
Ameer Hamza le 30 Déc 2020
I am glad to be of help!!!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Contour Plots dans Centre d'aide et File Exchange

Produits

Version

R2018b

Tags

Question posée :

le 29 Déc 2020

Commenté :

le 30 Déc 2020

Community Treasure Hunt

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

Start Hunting!

Translated by