% Draw a scalar field on a sphere function anim_globe(fname) % load example data load levitus_data.octave % minimum temperatur is -3 % put continents to -4 temp(isnan(temp)) = -4; % add a the colormap entry for % continents in gray map = [0.7 0.7 0.7; colormap]; colormap(map) % close the globe lon = [lon; 365.5]; temp = [temp; temp(1,:)]; % convert to sperical coordinates phi = lon*pi/180; theta = (90 - lat)*pi/180; [phi,theta] = ndgrid(phi,theta); % cartesian coordinates x = sin(theta) .* cos(phi); y = sin(theta) .* sin(phi); z = cos(theta); % plot the globe with color % representing sea surface temperature surf(x,y,z,temp) shading flat title('Sea Surface Temperature'); % don't show axes axis off % rotate the camera m = moviefile(fname); for angle=0:0.1:2*pi set(gca,'CameraPosition',20*[cos(angle) -sin(angle) .5]); drawnow m = movieaddframe(m); end m = movieclose(m);