Slice along a curved plane

It is easy to plot slices along a straight line plane (e.g. x=-50, and y=40 in the first figure) using the slice function.
[x,y,z]=meshgrid(-55:0.1:-25,30:0.1:60,1:1:150); slice(x,y,z,c,-50,40,[]); shading flat;
However, how can I get a slice along a curved plane (like the second figure)?

 Accepted Answer

uxsmfu
uxsmfu on 8 Nov 2018
After some digging, problem solved. I figured I should share the solution here.
The index terms (xd,yd,zd) need to be 2-D.
[yd,zd]=meshgrid(lat,depth);
[xd,zd]=meshgrid(lon,depth);
slice(x,y,z,c,xd,yd,zd);

1 Comment

"After some digging, problem solved. I figured I should share the solution here. The index terms (xd,yd,zd) need to be 2-D."
Basically, what I already said a day earlier in my answer: "Just pass a matrix of location for your x and y slice location"
Sometimes, you wonder why bother answering questions...

Sign in to comment.

More Answers (1)

Guillaume
Guillaume on 7 Nov 2018
how can I get a slice along a curved plane
Just pass a matrix of location for your x and y slice location instead of fixed -50, 40. There's even an example in the documentation of slice

Tags

Asked:

on 7 Nov 2018

Commented:

on 8 Nov 2018

Community Treasure Hunt

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

Start Hunting!