Lorenz Equation || Vector lengths should be the same
显示 更早的评论
Hi, im trying to plot the lorenz butterfly using the equations. I can't get past the error "vectors must be of equal length." I understand that this means that one of my vairables has more/lesser points compared to the other two, but I can't figure out how. I can tell you that it is variable z because on plotting 2-D Plot(x,y) works but plot(y,z) and plot(x,z) dont work for the same error. Can someone tell me how to fix this?
This is my code:
x(1) = normrnd(0,1);
y(1) = normrnd(0,1);
z(1) = normrnd(0,1);
sigma= 10;
rho=28;
time = 0.05;
beta= 8/3;
for i = 2:1000
x(i) = x(i-1) + time*sigma*(y(i-1)-x(i-1));
y(i) = y(i-1) + time*(x(i-1)*(rho-z(i-1))-y(i-1));
z(i) = z(i-1) + time*(x(i-1)*y(i-1)-beta*z(i-1));
end
figure
plot3(x,y,z)
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!