Professional Documents
Culture Documents
html
Contents
The system
The system
Consider the nonlinear system
dsolve can't solve this system. I need to use ode45 so I have to specify an initial value
f = @(t,x) [-x(1)+3*x(3);-x(2)+2*x(3);x(1)^2-2*x(3)];
Plotting components
I can plot the components using plot. For example, to plot the graph of I give the command:
plot(t,xa(:,2))
title('y(t)')
xlabel('t'), ylabel('y')
1 of 5 11/3/2018, 9:10 PM
Using ode45 to solve a system of three equations https://www3.nd.edu/~nancy/Math20750/Demos/3dplots/dim3system.html
3 D plot
I can plot the solution curve in phase space using plot3.
plot3(xa(:,1),xa(:,2),xa(:,3))
grid on
title('Solution curve')
2 of 5 11/3/2018, 9:10 PM
Using ode45 to solve a system of three equations https://www3.nd.edu/~nancy/Math20750/Demos/3dplots/dim3system.html
and I would like to use a loop to solve and plot the solution for .
syms t x a
g = @(t,x,a)[-x(1)+a*x(3);-x(2)+2*x(3);x(1)^2-2*x(3)]
for a = 0:2
[t,xa] = ode45(@(t,x) g(t,x,a),[0 1.5],[1 1/2 3]);
figure
plot(t,xa(:,2))
title(['y(t) for a=',num2str(a)'])
end
g =
@(t,x,a)[-x(1)+a*x(3);-x(2)+2*x(3);x(1)^2-2*x(3)]
3 of 5 11/3/2018, 9:10 PM
Using ode45 to solve a system of three equations https://www3.nd.edu/~nancy/Math20750/Demos/3dplots/dim3system.html
4 of 5 11/3/2018, 9:10 PM
Using ode45 to solve a system of three equations https://www3.nd.edu/~nancy/Math20750/Demos/3dplots/dim3system.html
5 of 5 11/3/2018, 9:10 PM