- #1
MathematicalPhysicist
Gold Member
- 4,699
- 372
I use the following script and function in MatLab, but get three errors.
I shall first write down the code and after that the errors that I get.
Here are the errors:
How to fix these errors?
Thanks!
I shall first write down the code and after that the errors that I get.
Matlab:
function yprime = lorenz_de(t,y)
%LORENZ_DE Lorenz equations.
% yprime = lorenz_de(t,y).
yprime = [10*(y(2)-y(1))
28*y(1)-y(2)-y(1)*y(3)
y(1)*y(2)-8*y(3)/3];
Matlab:
%LORENZ_RUN ODE solving example: Lorenz.
tspan = [0 50]; % Solve for 0 <= t <= 50.
yzero = [0;1;0]; % Initial conditions.
[t,y] = ode45(@lorenz_de,tspan,yzero);
plot(y(:,1),y(:,3)) % (y_1,y_3) phase plane.
xlabel('y_1','FontSize',14)
ylabel('y_3 ','FontSize',14,'Rotation',0,'HorizontalAlignment','right')
title('Lorenz equations','FontSize',16,'FontWeight','normal')
Here are the errors:
Code:
Error using odearguments (line 93)
LORENZ_DE must return a column vector.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in lorenz_run (line 5)
[t,y] = ode45(@lorenz_de,tspan,yzero);
How to fix these errors?
Thanks!