繁体   English   中英

如何在MATLAB中绘制2个曲面及其相交曲线?

[英]How to plot 2 surfaces and their intersection curve in MATLAB?

我有两个曲面的方程,我想绘制它们并突出它们的交点我的代码看起来像这样

t=linspace(-1,1,100);

x=t;

y=t;

z=cos(t.^8+12);

plot3(x,y,z,'g-','linewidth',3)

hold on

[x,y]=meshgrid(-2:2,-2:2); surf(x,y,z)

这给了我表面 z = f(x,y) 的图,但我不知道如何绘制平面 x=y

根据进一步的问题详细信息进行编辑。

这可能是一个有趣的起点。 下面是一个使用patch()函数创建矩形平面 x = y 的脚本。 patch 函数采用矩形的角坐标绘制 3D 情况 (x,y,z) 坐标。 不幸的是,我无法从上面的代码中获得曲面图。 所以交叉点的讨论是另一个时间的故事。

函数调用:

patch(X_Coordinates,Y_Coordinates,Z_Coordinates,Colour);

绘制 XY 平面和线函数

%***************************************************%
%3D line plot%
%***************************************************%

x = linspace(-1,1,100);
y = linspace(-1,1,100);
z = cos(x.^8+12);
plot3(x,y,z,'g-','linewidth',3)

%***************************************************%
%3D surface plot%
%***************************************************%

hold on
[x,y] = meshgrid(-2:0.01:2,-2:0.01:2);
z = cos(x.^8+12);
% surf(x,y,z);

%***************************************************%
%Plotting the xy-plane%
%***************************************************%

Plane_Top = 255;
Plane_Bottom = -255;
Plane_Width = 4;

%Using plane attributes to set patch points%
X = [-Plane_Width/2 -Plane_Width/2 Plane_Width/2 Plane_Width/2];
Y = [-Plane_Width/2 -Plane_Width/2 Plane_Width/2 Plane_Width/2];
Z = [Plane_Bottom Plane_Top Plane_Top Plane_Bottom];

%Plotting characteristics%
Colour = [252/255 148/255 3/255];
patch(X,Y,Z,Colour);
view(3);
grid on;
xlabel("X-Axis"); ylabel("Y-Axis");
title("Plotting the XY-Plane and Line Function");

使用MATLAB版本:R2019b

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM