1

我有 12 个矩阵,其中包含从 0 到 99 的数字。每个矩阵都是 1446x1124 双倍,对应一个月。我也有纬度和经度矩阵,每个矩阵也是 1446x1124。我想知道如何制作一个 Hovmuller 图(经度与时间图或纬度与时间图),它表示 0 到 99 之间的给定数字在 12 个矩阵中的出现。

4

2 回答 2

0

这是一个使用contourf的示例。诀窍在于适当地对 3D 数组进行采样:

x=linspace(0,pi,20);
y=linspace(0,pi,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(:))+rand(size(X3d));
dat2dx=7*sin(X2d)+5*cos(y(5))+T2dx/max(T2dx(:))+rand(size(X2d)); % at y(5)
dat2dy=7*sin(x(12))+5*cos(Y2d)+T2dy/max(T2dy(:))+rand(size(Y2d));  % at x(12)
%%
figure(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)')
于 2016-09-14T13:07:05.497 回答
-1

假设您有一个 12x100 矩阵M,每个字段中都有出现次数,绘制它们非常简单。

M = rand(12,100);
plot(M) % Plots 100 lines
plot(M') % Plots 12 lines
plot(sum(M)) % Plots the sum of 100 lines
plot(sum(M')) % Plots the sum of 12 lines
contour(M) % Gives the contour plot
surf(M) % Gives the surface plot

如果您不知道如何创建 M,我只会提示使用 2 个 for 循环不会太难。

于 2012-12-27T08:51:42.623 回答