Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Help with 4D plot Date: Fri, 9 Jul 2010 05:33:06 +0000 (UTC) Organization: Macquarie University Lines: 31 Message-ID: <i16cai$7t$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-05-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1278653586 253 172.30.248.35 (9 Jul 2010 05:33:06 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 9 Jul 2010 05:33:06 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 2411313 Xref: news.mathworks.com comp.soft-sys.matlab:651664 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