I'm calculating the jacobian for a two-body problem, which is defined like so

I have set up my system of equations as follows
syms y1(t) y2(t) y3(t) y4(t)
r = sqrt(y1^2 + y2^2)
y3 = diff(y1)
y4 = diff(y2)
yd = [y3; y4; -y1/r^3; -y2/r^3]
jacobian(yd, [y1 y2 y3 y4])
However, when I run the jacobian function I get the following error
The second argument must be a vector of variables.
What am I doing wrong?
EDIT:
I have also tried parametrizing y for t y(t) to no avail.
As the error message suggests that the second argument must be a vector of variables, whereas in your case it is:
[y1, y2, 1, 1].Also there is no need to initialize them as
symfunclass i.e.y1(t),y2(t),y3(t)andy4(t), you can define them assymclass instead i.e.y1,y2,y3andy4So, by initializing them as
symand removing the lines where you makey3andy4equal to1, i.e.you will get this output: