用MATLAB获得三维曲面图的语言? 50
浏览:1031
我想获得如下三维曲面图,用以下语言却得到2D图(提示尝试引用非结构体数组的字段),不知道哪里错了
请懂程序语言的大大们,帮忙解决一下。谢谢
网上查到语言:
[xz,y,z] = peaks;
f = figure;
[~, hc] = contourf(xz, y, z);
a1 = gca;
a2 = axes('Parent', f, 'Position', a1.Position);
hs = surf(xz, y, z, 'Parent', a2);
a1.Color = 'none';
a2.Color = 'none';
a1.ZLim = [0 1];
a2.ZLim = [-9 9];
a1.XTick = [];
a1.YTick = [];
a1.ZTick = [];
a1.Box = 'off';
a2.Box = 'off';
% Call after setting desired view on a2 (surf plot)
a1.View = a2.View;
把这段语言用MATLAB2014a实现出来是如下的2D图
红字提示:尝试引用非结构体数组的字段。不知道上面语言哪里有错误