I am trying to solve the Duffing's equation in MATLAB.
$ m\ddot{y}+c\dot{y}+ky+k_{3}y^{3} = f(t) $
where $ f(t) = A \sin{\omega t}$
To do that I wrote a function to be given to the ode45.
function [F] = ode_fun(t,y)
F = zeros(size(y));
F(1) = y(2);
F(2) = -k*y(1)-c*y(2)-k3*y(1)^3+A*sin(omega*t);
end
And then I call the ode function:
[t,u] = ode45('ode_fun',[0 T],[0 0]);
Is this the right way to do it?
Because I am expecting to obtain a cubic function when plotting the "force vs displacement" plot but I actually obtain a straight line.
EDIT: I'll give you also the numerical values I used for the simulation.
Basically I started from a linear equation I found in an example and then I added the nonlinear term to check if my code was able to distinguish between linear and nonlinear dynamic systems.
The values of the linear case are: $m = 1$ , $k = 10^4$, $ c = 40$.
Then I added the nonlinear term as $ k_3 = 11*10^4$
As forcing term I decided to use a sine wave having $A = 30$ and $\omega = 10$.
The final simulation time is $T = 60$
EDIT: the complete code I am testing is the one I talked about in this other question I posted 2D cross section from 3D surface
I am trying to understand if this procedure works for nonlinear parameter identification