How do I solve the following second order differential equation?

1 view (last 30 days)
Can you give me the code on how to solve the following equation?
1.4x'' + 4x' + 1700x = - [-8x' + 20(x')^3 + 100x - 2.5x^3]
Thanks!

Answers (1)

Ramanuja Jagannathan
Ramanuja Jagannathan on 25 Oct 2017
Please find below the documentation link showing how to represent differential equations in MATLAB and solve them. https://www.mathworks.com/help/symbolic/solve-a-single-differential-equation.html
Hope this helps
  2 Comments
John O'Brian
John O'Brian on 25 Oct 2017
Edited: Torsten on 26 Oct 2017
Hi I have the following code:
syms y(t)
[V] = odeToVectorField(1.4*diff(y, 2) == 8*diff(y)-20*(diff(y)).^3-100*y+2.5*y.^3-4*diff(y)-1700*y);
M = matlabFunction(V,'vars', {'t','Y'});
sol = ode45(M,[0 20],[0.01 0]);
opts = odeset('OutputFcn',@odephas2); % Options Structure
tspan = linspace(0, 1, 100); % Times For Evaluation
ic = [0 1]; % Initial Conditions
[t, xt] = ode45(EqnFcn, tspan, ic);
figure(1)
[t, xt] = ode45(EqnFcn, tspan, ic, opts);
title('Phase Plane Plot')
axis equal
figure(2)
plot(t, xt)
grid on
title('Time Domain Plot')
EqnSubc = regexp(sprintf('%s\n',Eqn_subs), '\n','split');
legend(EqnSubc{1:end-1})
I am trying to plot a phase plane plot for a variety of initial conditions. I think it might require a for loop. Can you adjust the code and show me how to do it please?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!