Generate 3D plots using 3D variables (Lat,lon,depth,Salinity)

26 views (last 30 days)
Hey!
I've converted 4D-double variables from netCDF files and have these variables (i.e., temperature/salinity) in a three-dimensional double format (lon x lat x depth), I used [x y z ] = meshgrid(lon,lat,depth) in order to make each variable the same size. Each variable is a double, and looking at the forums and mathworks, I should be able to generate 3D plots (i.e., surfc/contour3). However, when I attempt to use these plot formats, I get errors such as X,Y,Z vectors must be the same length (which they are after using meshgrid?), or 'values must be scalar, vector or an array of numeric type' but again, after using TF = isnumeric(variable), each parameter used gets ans (1).
I've tried using the lon, lat and depth variables as they come (not meshgridded), but then I get errors with matrix dimensions must agree.
Does anyone know how to resolve these issues?

Accepted Answer

Cris LaPierre
Cris LaPierre on 7 Sep 2022
Edited: Cris LaPierre on 7 Sep 2022
surfc and contour3 do not accept 3D variables as inputs. See here:
and here
Lat and Lon can be a vector or 2D matrix, and depth must be a 2D matrix.
  7 Comments
Francesca Evans
Francesca Evans on 7 Sep 2022
Hey Cris!
Thank you so much for all this assistance and guidance, the contourf plots look a lot better at what I'm trying to show, and I can always use subplots to show the change in salinity with different depths.
Cheers for this!!
Francesca :)

Sign in to comment.

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!