Solve a non linear differential equation

Hello,
I have an equation like: Az"+Bz'+Cz'sin(Dz+E)+Fz=G with A,B,C,D,E,F,G are constant, and initial conditions known.
I have to solve it using Matlab, but I really don't know how to do, even after looking for information on Internet, could you help me or tell me what function I have to use?
Thank you in advance,
Romain CHAUDET

 Accepted Answer

You can find the technique of creating a companion matrix from a differential equation in most differential equation textbooks, so I will spare you the discussion here.
[A,B,C,D,E,F,G] = deal(3,5,7,11,13,17,19);
odez = @(t,z) [z(2); (-B.*z(2)-C.*z(2).*sin(D*z(1)+E)-F.*z(1)+G)./A];
ts = linspace(1, 10, 250);
[t,z] = ode45(odez, ts, [0; 0]);
figure(1)
plot(t, z)
grid
legend('z(t)', 'z’(t)')

2 Comments

Thank you very much for your help, this worked well!
Romain CHAUDET

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!