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

New to MATLAB?

Thread Subject:
Help with 4D plot

Subject: Help with 4D plot

From: Claire

Date: 9 Jul, 2010 05:33:06

Message: 1 of 1

I have a 4D dataset of the ocean, comprised of latitude, longitude, depth and time with the variable 'temperature' recorded within these bounds. I want to plot the temperature of a volume of water within 3D space, but can't find the command to do this.

I understand that I can not plot this for all time in the one graph, so I am selecting a specific time and then using the 'squeeze' command to remove this extra dimension.

I created a meshgrid for my 'Z' variable since I was not able to just use the 'odepth' vector variable - I kept getting an error stating that Z could not be a vector but needed to be an m-n array. The meshgrid seems to have fixed this problem.

When I run the code below it falls apart at my 'surf' command, and I get the error message "cdata must be an m-by-n matrix or m-by-n-by-3 array", which I don't understand.

I can visualise the plot I want: lat and lon on the x and y axis, depth on the z axis, with temperature defining the shading of the plot. Am I using the wrong command?

x=find(olat<=-65.25&olat>=-70.25); %specify latitude
y=find(lon>=80.4&lon<=179.4); %specify longitude
%z=find(odepth>=0); %depth not specified = all depths
t=find(time==1959); %specify time


surf(x,y,zmesh,(squeeze(datanan(x,y,:,t)))) %THIS LINE IS THE PROBLEM
shading flat %adds or removes grid lines
shading interp %smooths the plot to remove the pixels
title ('Temperature - Jan 1959')
xlabel('Latitude (degrees north)')
ylabel('Longitude (degrees east)')

Any help anyone could offer is very much appreciated!

Tags for this Thread

No tags are associated with 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