How do you plot an elevation line across a mesh dataset?

2 views (last 30 days)
I want to plot a line graph showing how elevation changes along the x or y axis. I want to be able to control the x or y intercept and see how elevation changes across a transect. I have x,y and z data which has been interpolated using
xi=linspace(min(x),max(x),1000) yi=linspace(min(y),max(y),1000) [xi yi]=meshgrid(xi,yi) zi=griddata(x,y,z,xi,yi)
Is there an easy way of producing simple plot line graphs that show how elevation (z) changes along different transects (e.g yi = 20,25,30,35,40).
Any help would be much appreciated!
John

Accepted Answer

Ankit Bhardwaj
Ankit Bhardwaj on 24 Apr 2017
There can be multiple ways to do this.
1. You can use 'find' function to find the indices when yi has a constant value (e.g. yi = 20), and then use those indices to find the corresponding values of xi and zi. You can follow the same steps for finding xi and zi values corresponding to other yi values (such 25, 30, 35 etc.). Finally you can use these values to plot trend lines on a 3d plot. For more information on 'find' function, please go through the following documentation.
https://www.mathworks.com/help/releases/R2017a/matlab/ref/find.html
2. You may also use 'slice' function. Please go through the following documentation to learn more about this.
https://www.mathworks.com/help/releases/R2017a/matlab/ref/slice.html

More Answers (0)

Categories

Find more on 2-D and 3-D Plots 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!