如何在图表上绘制矩阵中的元素?软件
How to plot elements in the matrix on the graph? MATLAB
我刚刚开始使用 MATLAB。所以请帮助我。
如果我有一个m*n矩阵。
我想绘制一个 3 维图,其中 x 轴和 y 轴分别作为 x 索引和 y 索引。在 z 轴上,矩阵中 i,j 处的元素。
如何在 MATLAB 中绘制它?
假设你的 m*n 矩阵是 A
您可以通过调用
将数据绘制为 surface
figure %# opens a new figure, otherwise you'll overwrite an existing one
surf(A)
如果要添加 x 和 y 索引
surf(xIndices, yIndices, A)
如果要散点图,需要先为坐标创建与A大小相同的数组
[xx,yy] = meshgrid(xIndices, yIndices);
plot3(xx(:), yy(:), A(:), 'o');
or
scatter3(xx(:), yy(:), A(:))
我刚刚开始使用 MATLAB。所以请帮助我。
如果我有一个m*n矩阵。
我想绘制一个 3 维图,其中 x 轴和 y 轴分别作为 x 索引和 y 索引。在 z 轴上,矩阵中 i,j 处的元素。
如何在 MATLAB 中绘制它?
假设你的 m*n 矩阵是 A
您可以通过调用
将数据绘制为 surfacefigure %# opens a new figure, otherwise you'll overwrite an existing one
surf(A)
如果要添加 x 和 y 索引
surf(xIndices, yIndices, A)
如果要散点图,需要先为坐标创建与A大小相同的数组
[xx,yy] = meshgrid(xIndices, yIndices);
plot3(xx(:), yy(:), A(:), 'o');
or
scatter3(xx(:), yy(:), A(:))