matlab上的三维图
Three dimensional plot on matlab
我正在尝试做一个与附件相似的图形。
我有一个带有日期(x 轴)的 (224x1) 向量,一个带有到期时间(y 轴)的 (10x1) 向量和一个带有值(z 轴)的 (224x10) 矩阵。
我尝试了 surf(X, Y, Z) 但出现错误 ("data dimensions must agree")。
我怎样才能把它结合起来制作一个像附件那样的情节?
谢谢V!
编辑:第二个图是我根据 Luis Mendo 的建议得到的:
做
[X,Y]=meshgrid(x,y);
surf(X,Y,Z);
您需要创建网格才能绘制冲浪图。 X ,Y 和 Z 需要大小相同!
使用
surf(Y,X,Z)
来自documentation(强调已添加):
surf(x,y,Z)
and surf(x,y,Z,C)
, with two vector arguments replacing
the first two matrix arguments, must have length(x) = n
and
length(y) = m
where [m,n] = size(Z)
. In this case, the vertices
of the surface patches are the triples (x(j), y(i), Z(i,j)).
Note that x
corresponds to the columns of Z
and y
corresponds to
the rows.
我正在尝试做一个与附件相似的图形。
我有一个带有日期(x 轴)的 (224x1) 向量,一个带有到期时间(y 轴)的 (10x1) 向量和一个带有值(z 轴)的 (224x10) 矩阵。
我尝试了 surf(X, Y, Z) 但出现错误 ("data dimensions must agree")。
我怎样才能把它结合起来制作一个像附件那样的情节?
谢谢V!
编辑:第二个图是我根据 Luis Mendo 的建议得到的:
做
[X,Y]=meshgrid(x,y);
surf(X,Y,Z);
您需要创建网格才能绘制冲浪图。 X ,Y 和 Z 需要大小相同!
使用
surf(Y,X,Z)
来自documentation(强调已添加):
surf(x,y,Z)
andsurf(x,y,Z,C)
, with two vector arguments replacing the first two matrix arguments, must havelength(x) = n
andlength(y) = m
where[m,n] = size(Z)
. In this case, the vertices of the surface patches are the triples (x(j), y(i), Z(i,j)). Note thatx
corresponds to the columns ofZ
andy
corresponds to the rows.