Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MATLAB中三维曲面上的附加轴_Matlab - Fatal编程技术网

MATLAB中三维曲面上的附加轴

MATLAB中三维曲面上的附加轴,matlab,Matlab,假设我使用 [X,Y,Z] = peaks(25); figure surf(X,Y,Z); 如何将附加的x轴和y轴以及标签添加到z=0平面,如图中所示的红色平面?我想保持原来的轴不变。 我只会画我自己的假轴。我不确定是否有更好的解决方案,但这一个有效 [X,Y,Z] = peaks(25); figure surf(X,Y,Z); hold on; %define the plot limits xlim_arr = [-4 4]; ylim_arr = [-5 5]; zlim_arr

假设我使用

[X,Y,Z] = peaks(25);
figure
surf(X,Y,Z);
如何将附加的x轴和y轴以及标签添加到z=0平面,如图中所示的红色平面?我想保持原来的轴不变。

我只会画我自己的假轴。我不确定是否有更好的解决方案,但这一个有效

[X,Y,Z] = peaks(25);
figure
surf(X,Y,Z);

hold on;

%define the plot limits
xlim_arr = [-4 4];
ylim_arr = [-5 5];
zlim_arr = [-10 10];

%fix the limits of the real axes
xlim(xlim_arr);
ylim(ylim_arr);
zlim(zlim_arr);

%add grid and labels through all x-points
for i=xlim_arr(1):xlim_arr(2)
    plot3([i i],[ylim_arr(1) ylim_arr(2)], [0 0], 'Color', [0.7 0.7 0.7], 'LineWidth',0.4);

    text(i, ylim_arr(1)-0.4, 0, num2str(i));
    text(i, ylim_arr(2)+0.4, 0, num2str(i));
end

%add grid and labels through all y-points
for i=ylim_arr(1):ylim_arr(2)
    plot3([xlim_arr(1) xlim_arr(2)], [i i], [0 0], 'Color', [0.7 0.7 0.7], 'LineWidth',0.4);

    text(xlim_arr(1)-0.4, i, 0, num2str(i));
    text(xlim_arr(2)+0.4, i, 0, num2str(i));
end

%add the bold frame to highlight the fake axes
px = [xlim_arr(1) xlim_arr(1) xlim_arr(2) xlim_arr(2) xlim_arr(1)];
py = [ylim_arr(1) ylim_arr(2) ylim_arr(2) ylim_arr(1) ylim_arr(1)];
pz = [0 0 0 0 0];

plot3(px,py,pz, 'k', 'LineWidth', 0.5);

只是想澄清一下:你想要图中的两个轴,还是用红色的轴替换你的轴?我想要保留原来的轴(编辑我的帖子)。好的,谢谢。我更喜欢matlab命令,但这种方法也适用。谢谢