MATLAB: The subs function returns zero instead of a term

  Kiến thức lập trình

I’m dealing with a problem in Matlab. I was following this tutorial: https://shorturl.at/bhwyP

The part of the code that is the same as in the video behaves differently that expected. I’m trying to replace partial differential expressions in a simple equation with a symbolic expressions from the HOLDER_list. It seems to work for the first pair: THE_X and x, but when it comes to the second therm, diff(x,t) is substituted with 0 instead of THE_XD as I would expect.

Here is the code:

clear
syms m k b F
syms t x(t)
syms THE_X THE_XD THE_XDD
HOLDER_list = [THE_X,THE_XD,THE_XDD];
actual_list = [x, diff(x,t), diff(x,t,2)];

v =diff(x,t)
v_new = subs(v, actual_list, HOLDER_list)

New contributor

mathematix is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT