independent variable shows up as an arrow after using subs
Show older comments
After using subs to replace a variable 'u' in an array H with the time dependent function 'u(t)', the array shows '(t -> u(t)) at every occurrence of u in the array. When I then try to solve this array as a system of ODE's using dsolve, the solver fails saying the system does not seem to be linear. If I manually copy the array into the command window, and remove all occurrences of 't ->', the system is solved normally.
To illustrate,
H1=u^2+w;
H2=u+w^2;
dH1du=diff(H1,u);
dH1dw=diff(H1,w);
dH2du=diff(H2,u);
dH2dw=diff(H2,w);
dH=[(dH1du+dH2du);(dH1dw+dH2dw)]
syms u(t) w(t)
dH=subs(dH,[u,w],[u(t),w(t)])
ode1=diff(u)==dH(1);ode2=diff(w)==dH(2);odes=[ode1;ode2]
uw=dsolve(odes)
gives the output:
dH =
2*u + 1
2*w + 1
dH =
2*(t -> u(t)) + 1
2*(t -> w(t)) + 1
odes(t) =
diff(u(t), t) == 2*(t -> u(t)) + 1
diff(w(t), t) == 2*(t -> w(t)) + 1
Error using mupadengine/feval (line 163)
This system does not seem to be linear.
Error in dsolve>mupadDsolve (line 336)
T = feval(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 193)
sol = mupadDsolve(args, options);
Error in matlabwebsitequestion (line 17)
uw=dsolve(odes)
If, instead, I manually replaced the last two lines with the following:
ode1=diff(u)==2*(u(t)) + 1;ode2=diff(w)==2*(w(t)) + 1;odes=[ode1;ode2]
uw=dsolve(odes)
I get the output:
odes(t) =
diff(u(t), t) == 2*u(t) + 1
diff(w(t), t) == 2*w(t) + 1
uw =
w: [1x1 sym]
u: [1x1 sym]
Note that I couldn't declare 'syms u(t) w(t)' from the beginning because I need the partial derivatives of H with respect to these two variables, and if I had declared them with their time functionality from the beginning, I get:
Error using sym/diff (line 26)
All arguments, except for the first one, must not be symbolic functions.
Error in matlabwebsitequestion (line 7)
dH1du=diff(H1,u);
Accepted Answer
More Answers (0)
Categories
Find more on Equation Solving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!