我正在使用 MATLAB 绘制 Lorenz 吸引子,并且想知道如何将 XYZ 坐标导出到 3D 可打印文件!我在从 XYZ 坐标到表面时遇到了麻烦(我应该这样做吗?)。此外,即使将 Lorenz Attractor 视为“表面”对我来说似乎也不正确,因为我的理解是它更像是一条“路径”。
到目前为止我的代码:
clear all; clc; clf;
dt = .01;
n = 100; %Number of Drawings
t = 0:dt:n; %Time Scale
%INITIAL CONDITIONS
x = 1;
y = 1;
z = 1;
xyz0 = [x y z];
%SOLVE ODE
[t,xyz] = ode45(@rhs, t, xyz0);
x = xyz(:,1);
y = xyz(:,2);
z = xyz(:,3);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%% PLOTTING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%plot3(x,y,z);
rotate3d on;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%% RHS FOR ODE45 %%%%%%%%%%%%%%%%%%%%%%%%
function xyzdot = rhs(t,xyz)
sigma = 10;
b = 8/3;
r = 100;
x = xyz(1);
y = xyz(2);
z = xyz(3);
dxdt = sigma*(y - x);
dydt = r*x - y - x*z;
dzdt = x*y - b*z;
xyzdot = [dxdt; dydt; dzdt];
end
我之前试过这个:
[X,Y] = meshgrid(x,y);
surf(X, Y, z);
但没有任何工作。错误说 z 必须是一个矩阵,我有点迷茫。