From: Sarah Bonham on
Hi,
I am trying to plot a 3d image from a netcdf file using the variable temp_ym_dpth, which is ocean temperatures with depth.

The matrix is 3D: 20x144x288 (depth x long x lat).

I would like to plot a 3d profile of the Pacific, from 100E-300E and 90S-90N with depths 1 to 20.

So far I have tried surf(squeeze(temp_ym_dpth)) but it returns the error:

CData must be an M-by-N matrix or M-by-N-by-3 array
error in -> surf at 97
hh = double(graph3d.surfaceplot(args(:),'parent',parax));

I also tried defining the region first, but that didn't work either.

I typed ndim to check the dimensions in case it was 4D, but it is 3D.

I apologise if this is a simple question; I haven't been using matlab for long, but is there another way of producing a 3D image or could anyone tell me where I am going wrong?

any help is greatly appreicated;

thank you in advance,

Sarah
From: Walter Roberson on
Sarah Bonham wrote:
> Hi, I am trying to plot a 3d image from a netcdf file using the variable
> temp_ym_dpth, which is ocean temperatures with depth.
>
> The matrix is 3D: 20x144x288 (depth x long x lat).
> I would like to plot a 3d profile of the Pacific, from 100E-300E and
> 90S-90N with depths 1 to 20.
>
> So far I have tried surf(squeeze(temp_ym_dpth)) but it returns the error:
> CData must be an M-by-N matrix or M-by-N-by-3 array


A 3D plot would require two dimensions of coordinates and one dimension of
resulting values (the values stored in the matrix.)

As you have three dimensions of coordinates and one dimension of resulting
values, you are attempting to do a 4D plot.About the best you could hope for
in a case like this would be to do one surface per depth, with the FaceAlpha
largest for the bottom-most plot and smallest for the top-most plot, so that
you can get a general (but obscured) idea of what things are like at the lower
layers.

Beyond that, you need to work with plotting isosurfaces -- 3D plots that mark
the boundaries of areas that are all the same value. Sort of like a contour.

This kind of data, with 3 spacial directions and one measurement, are probably
best handled by voxel-viewing techniques, but Matlab is not very rich in voxel
handling tools.
From: Roger Stafford on
"Sarah Bonham" <eesb(a)leeds.ac.uk> wrote in message <hr9vpc$7cr$1(a)fred.mathworks.com>...
> Hi,
> I am trying to plot a 3d image from a netcdf file using the variable temp_ym_dpth, which is ocean temperatures with depth.
>
> The matrix is 3D: 20x144x288 (depth x long x lat).
>
> I would like to plot a 3d profile of the Pacific, from 100E-300E and 90S-90N with depths 1 to 20.
>
> So far I have tried surf(squeeze(temp_ym_dpth)) but it returns the error:
>
> CData must be an M-by-N matrix or M-by-N-by-3 array
> error in -> surf at 97
> hh = double(graph3d.surfaceplot(args(:),'parent',parax));
>
> I also tried defining the region first, but that didn't work either.
>
> I typed ndim to check the dimensions in case it was 4D, but it is 3D.
>
> I apologise if this is a simple question; I haven't been using matlab for long, but is there another way of producing a 3D image or could anyone tell me where I am going wrong?
>
> any help is greatly appreicated;
>
> thank you in advance,
>
> Sarah

I'm not sure what you want to see when you say "a 3d profile of the Pacific". The 'surf' function will allow you to show the temperature at a fixed depth as longitude and latitude vary over that range, or it would allow, say, temperature at a fixed latitude and varying longitude and depth. I don't know any way us poor deficient human beings can see a display of temperature as three different variables change independently. Do you? Any attempt to superimpose a number of the above types of display would produce a very bewildering picture.

Roger Stafford