MATLAB: Doesn’t diff() recognise the second variable

symbolicSymbolic Math Toolbox

syms x(t) m1 m2
xr = x;
xl = 0;
T = (m1 * diff(xl)^2) / 2 + (m2 * (diff(xr)^2)) / 2 % why doesn't it recognise that xr is a function of time?
Why is the different from this?
T = (m1 * diff(xl,t)^2) / 2 + (m2 * (diff(xr,t)^2)) / 2 % gives the expected result
whereas if i do
diff(xr) % it gives me the correct result?
What is going on here?

Best Answer

This works correctly in R2020a (Update 3):
syms x(t)
xr = x
diff(xr) % why doesn't it recognise that xr is a function of time?
T = diff(xr)
producing:
xr(t) =
x(t)
ans(t) =
diff(x(t), t)
T(t) =
diff(x(t), t)
I cannot reproduce the error.