Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Plotting a 3d ocean temperature map

Subject: Plotting a 3d ocean temperature map

From: Sarah Bonham

Date: 28 Apr, 2010 18:46:04

Message: 1 of 3

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

Subject: Plotting a 3d ocean temperature map

From: Walter Roberson

Date: 28 Apr, 2010 19:27:07

Message: 2 of 3

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.

Subject: Plotting a 3d ocean temperature map

From: Roger Stafford

Date: 28 Apr, 2010 19:28:05

Message: 3 of 3

"Sarah Bonham" <eesb@leeds.ac.uk> wrote in message <hr9vpc$7cr$1@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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us