by others help,
k = 1;
f = @(t,x) [x(2); -k * x(2) - x(1)^3 + 9.8 * cos(t)];
tspan = [0, 10];
xinit = [0, 0];
ode45(f, tspan, xinit)
If I do this I get a graph of x(1)vs t/x(2)vs t seperately, however the graph I wanted was x(2)vs x(1).
Can anyone help me with this?