Defining relationship for symbolic variable in MATLAB -


let's have symbolic variable "q" depends on symbolic variable "t". how define each symbolic variables.

t= sym('t'); q = sym('q(t)'); 

and have expression contains (when use pretty(expression))

result = blah1* diff(q(t),t) *blah2  

i want make particular part new variable. let's "qdot" in end, want this.

result2 = blah1*qdot*blah2 

i'm in process of figuring out. thank in advance.

you should use subs function. here how use particular question

function rewrite() t = sym('t'); q = sym('q(t)');  = sym('a'); blah1 = a^2; blah2 = t^3; result1 = blah1*diff(q,t)*blah2;  qdot = sym('qdot'); result2 = subs(result1, diff(q,t), qdot) % result2 = a^2*qdot*t^3; end 

note

result2 = subs(result1, 'diff(q(t),t)', qdot) 

and

newmiddle = sym('qdot'); result2 = subs(result1, diff(q,t), newmiddle) 

also give desired result.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

node.js - Node - Passport Auth - Authed Post Route hangs on form submission -

Does Firefox offer AppleScript support to get URL of windows? -