这是一个例子contourfcontourf。诀窍是在适当取样3 d数组:
x = linspace(0,π,20);y = linspace(0,π,10);t = 0:10:120;[X3d, Y3d T3d] = meshgrid (x, y, t);[X2d, T2dx] = meshgrid (x, t);[Y2d, T2dy] = meshgrid (y, t);dat3d = 7 * sin (X3d) + 5 * cos (Y3d) + T3d / max (T3d(:)) +兰德(大小(X3d));dat2dx = 7 * sin (X2d) + 5 * cos (y (5)) + T2dx / max (T2dx(:)) +兰德(大小(X2d));%在y (5) dat2dy = 7 * sin (x (12)) + 5 * cos (Y2d) + T2dy / max (T2dy(:)) +兰德(大小(Y2d));在x(12) % % %图(1);clf contourf (X2d, T2dx dat2dx); shading flat; colorbar ylabel('Time (days)') xlabel('X distance (km)') %% figure(2);clf contourf(Y2d,T2dy,dat2dy); shading flat; colorbar ylabel('Time (days)') xlabel('Y distance (km)') %% figure(3);clf subplot(221) contourf(squeeze(X3d(5,:,:)),squeeze(T3d(5,:,:)),squeeze(dat3d(5,:,:))); shading flat; colorbar ylabel('Time (days)'); xlabel('X distance (km)') title('Hovmoller at y(5)') subplot(222) contourf(squeeze(Y3d(:,12,:)),squeeze(T3d(:,12,:)),squeeze(dat3d(:,12,:))); shading flat; colorbar ylabel('Time (days)'); xlabel('Y distance (km)') title('Hovmoller at x(12)') subplot(223) contourf(squeeze(X3d(8,:,:)),squeeze(T3d(8,:,:)),squeeze(dat3d(8,:,:))); shading flat; colorbar ylabel('Time (days)'); xlabel('X distance (km)') title('Hovmoller at y(8)') subplot(224) contourf(squeeze(Y3d(:,17,:)),squeeze(T3d(:,17,:)),squeeze(dat3d(:,17,:))); shading flat; colorbar ylabel('Time (days)'); xlabel('Y distance (km)') title('Hovmoller at x(17)')