How to make a 3D plot where z data corresponds to different y axes?

1 view (last 30 days)
Hello, I am running into trouble when trying to make a 3D plot because I don't have one consistent y axis. I have some x values, and for each x I have some y values (but those ys are not always the same for different x values) and then each (x,y) has a z value.
So x is a vector with, say, 10 elements. y is a matrix with, say, 8x10 elements. And z is a matrix also with 8x10 elements.
But all 3D plots I've tried only accept y as a vector, not a matrix.
I've tried making y a single vector containing all the different y values, and then in z substituting NaN where there is no data for that x,y. But this runs into the problem that the plots don't simply ignore the NaNs and move onto the next point, they break the surface up. Attached are the x,y and z I used to try this if you want to recreate my problem. Just do surf(x,y,z).
Doing something like surf(x,y,z(~isnan(z))) doesn't work because then the length of z doesn't match with y.
So is there some way to accomplish this? Maybe some value instead of NaN that plots actually will just ignore?
Regards, Christy
  4 Comments
James Tursa
James Tursa on 7 Mar 2015
When I open the files, there are 11 x values, 20 y values, and 11 z values. So x matches z in size. But I still have no understanding how you are forming your (x,y,z) triplets from these values. When you write "... at every (x,y) ..." I don't understand how you are forming the (x,y) pairs from the 11 element x vector and the 20 element y vector.
Christy Simpson
Christy Simpson on 7 Mar 2015
Edited: Christy Simpson on 7 Mar 2015
Oh I'm sorry, I didn't save z properly. I've attached the correct one.

Sign in to comment.

Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!