Lorenz Equation || Vector lengths should be the same
Show older comments
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)
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!