我使用这个简单的Matlab代码绘制3d函数。突出情节边界的最佳方法是什么? (比如在边界画一条黄线)
clc;
clear all;
syms x y;
func = x^2 + 4*y^2 - 2*x^2*y+4;
ezsurf(func, [-5,5]);
grid on;
box on;
答案 0 :(得分:1)
可以使用hold on/off
:
1.使用 plot3
clc; clear all;
syms x y;
func = x^2 + 4*y^2 - 2*x^2*y+4;
figure;
ezsurf(func, [-5,5]);
grid on;
box on;
hold on;
y1 = -5:0.1:5; x1 = 5.*ones(size(y1)); z1 = x1.^2 + 4*y1.^2 - 2*x1.^2.*y1+4;
y2 = -5:0.1:5; x2 = -5.*ones(size(y2)); z2 = x2.^2 + 4*y2.^2 - 2*x2.^2.*y2+4;
x3 = -5:0.1:5; y3 = 5.*ones(size(x3)); z3 = x3.^2 + 4*y3.^2 - 2*x3.^2.*y3+4;
x4 = -5:0.1:5; y4 = -5.*ones(size(x4)); z4 = x4.^2 + 4*y4.^2 - 2*x4.^2.*y4+4;
plot3(x1, y1, z1, 'y', x2, y2, z2, 'y', x3, y3, z3, 'y', x4, y4, z4, 'y');
hold off;
你可以使用LineWidth专有权来使这些线更大。
结果:
2.使用 ezplot3 (参数曲线)
clear x y;
hold on;
x = {'5'; '(-5)'; 't'; 't'};
y = {'t'; 't'; '5'; '(-5)'};
for i = 1:size(x,1)
funz = [char(x(i)),'^2 + 4*',char(y(i)),'^2 - 2*',char(x(i)),'^2*',char(y(i)),'+4'];
h = ezplot3( char(x(i)), char(y(i)), funz, [-5, 5]);
set(h, 'Color', 'y', 'LineWidth', 2);
end
hold off;
结果: