How to create contour plot to show height?
Show older comments
I want to create a countour plot such that my x axis and y axis are the coordinates of the plane and my z axis is height. I want to creat a 2b plot (contour) such that my height is differentiated with color. My z value has no relation with xy value other that the first value of z is corresponding to the cobination of first two values of x and y.
For example my x, y and z vectors are:
AAA=1:1:1000;
BBB=1:1:1000;
CCC=2:2:2000;
3 Comments
DGM
on 18 Mar 2022
if there's no correlation between Z and X,Y, then you don't have a meaningful description of a 2D dataset.
If the x,y,z vectors are correlated, but scattered, then use griddata() to create gridded data that's compatible with what contour() expects.
Muhammad Qaisar Fahim
on 18 Mar 2022
DGM
on 18 Mar 2022
Okay, yeah. That's just scattered data. Walter's suggestion looks pretty good.
Accepted Answer
More Answers (1)
Walter Roberson
on 18 Mar 2022
0 votes
2 Comments
Muhammad Qaisar Fahim
on 18 Mar 2022
Edited: Walter Roberson
on 19 Mar 2022
Walter Roberson
on 19 Mar 2022
The first parameter to tricontour() needs to be the xy coordinates, each row being an x y pair.
The second parameter to tricontour() needs to be the triangular connectivity data.
You might want to use https://www.mathworks.com/help/matlab/ref/delaunaytriangulation.html and extract the Points and ConnectivityList properties of the result.
Categories
Find more on Red in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




