How substitute variable in Matlab? -
i have trouble set of equations. have:
x' = f(t, x, u) - it's set of equations - dimension n x1' = .. x2' = .. x3' = ..
and have u - it's vector (u1, u2, u3..)
how can substitute u in set of equations? example :
x1' = sin(t) * u1 + sin(u2) x2' = u2*x2 u1 = sin(1000t) u2 = cos(1000t)
and need
x1' = sin(t) * sin(1000t) + sin(cos(1000t)) x2' = cos(1000t) * x2
thank's.
well, assuming using symbolic toolbox:
syms t u1 u2 x2; x1prime = sin(t) * u1 + sin(u2); x2prime = u2 * x2;
then can use method or b. method a:
x1prime = subs(x1prime, [u1 u2], [sin(1000*t) cos(1000*t)]) x2prime = subs(x2prime, u2, cos(1000*t))
method b:
u1 = sin(1000*t); u2 = cos(1000*t); x1prime = subs(x1prime) x2prime = subs(x2prime)
i tested both methods on matlab r2011a. use works best you.
Comments
Post a Comment