Prev: Real world input
Next: ANN
From: Claire on
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

zmesh=meshgrid(x,y);

figure
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
colorbar
title ('Temperature - Jan 1959')
xlabel('Latitude (degrees north)')
ylabel('Longitude (degrees east)')
%%%%%%%%%%%%

Any help anyone could offer is very much appreciated!
Thanks,
Claire
 | 
Pages: 1
Prev: Real world input
Next: ANN