轴标签问题 [英] Axis labeling question
本文介绍了轴标签问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过运行以下我编写的matlab函数,图中的x轴和y轴互换.
The x-axis and y-axis are interchanged in the figure by running the following matlab function I wrote.
有人可以告诉我问题出在哪里还是帮助我解决它?预先感谢您的帮助.
Could anyone tell me where the problem is or help me fix it? Thanks in advance for any help.
function axislabeling(n)
x=1:1:n;
y=1:1:n;
z=zeros(n,n);
for i=1:n
for j=1:n
z(i,j)=i;
end
end
surf(x,y,z(x,y))
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')
推荐答案
我怀疑问题不是不是轴标注错误,而是图形不是您期望的那样.原因是可以访问(行,列)matlab矩阵(即(y,x)
),而不是根据需要访问(x,y)
.因此,当您设置z(i,j)=i
时,您会得到错误的方向坡度.
I suspect the problem is not that the axes are mislabelled but that the graph is not what you expect. The reason is that matlab matrices are accessed (row, column) -- ie, (y,x)
-- rather than (x,y)
as you have it. So when you're setting z(i,j)=i
you're getting the slope in the wrong direction.
这篇关于轴标签问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文