Not solving differential equation in terms of inherent variable (subs)
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to solve a differential equation (T) in terms of y. The equation is the product of some functions (u & u_m) which were previously computed and depend on y. However, it keeps giving the output of T in terms of eq, instead of y, even when I use subs. I want the output only in terms of y and b. Here is the code:
syms b1 b2
u = dsolve('D2u = -1', 'u(0) = b1*Du(0)', 'u(1) = -b2*Du(1)', 'y')
u_m = int(u,0,1);
syms bt1 bt2 N
eq = -N*u/u_m;
eq = subs(eq);
T = dsolve('D2T = eq', 'T(0) = bt1*DT(0)', 'T(1) = - bt2*DT(1)', 'y')
0 Kommentare
Antworten (1)
Star Strider
am 22 Jan. 2015
The syntax you’re using may be a problem. In R2014b, this code (note the absence of the single quotes, and presence of ‘==’):
syms b1 b2 u(y)
Du = diff(u);
D2u = diff(u,2);
u = dsolve(D2u == -1, u(0) == b1*Du(0), u(1) == -b2*Du(1), y);
u_m = int(u,0,1);
syms bt1 bt2 N T(u)
DT = diff(T);
D2T = diff(T,2);
eq = -N*u/u_m;
eq = subs(eq);
T = dsolve(D2T == eq, T(0) == bt1*DT(0), T(1) == - bt2*DT(1), y);
T = simplify(T, 'steps', 10)
pretty(T)
produces this result:
T =
(2*N*(b1 + b2 + 1)*(bt1 + y + 3*bt1*bt2 + 3*bt2*y - bt1*y^3 - bt2*y^3 - y^3))/((bt1 + bt2 + 1)*(4*b1 + 4*b2 + 12*b1*b2 + 1))
3 3 3
N (b1 + b2 + 1) (bt1 + y + 3 bt1 bt2 + 3 bt2 y - bt1 y - bt2 y - y ) 2
------------------------------------------------------------------------
(bt1 + bt2 + 1) (4 b1 + 4 b2 + 12 b1 b2 + 1)
Is that what you want?
2 Kommentare
Star Strider
am 22 Jan. 2015
Using subs may be the problem.
I rearranged your code a bit, without altering the individual assignments.
See if this does what you want:
syms b1 b2 u(y) bt1 bt2 N T(u)
Du = diff(u);
D2u = diff(u,2);
u = dsolve(D2u == -1, u(0) == b1*Du(0), u(1) == -b2*Du(1), y);
u_m = int(u,0,1);
DT = diff(T);
D2T = diff(T,2);
eq = -N*u/u_m;
eq = subs(eq);
T = dsolve(D2T == eq, T(0) == bt1*DT(0), T(1) == - bt2*DT(1), y);
T = simplify(T, 'steps', 10)
% pretty(T)
uTu_m = u*T/u_m
exp_21 = int(uTu_m,0,1)
eqn_21 = exp_21 == 1;
sol_N = solve(eqn_21, N);
sol_N_var = symvar(sol_N); % ‘u’ Not Present
sol_N = simplify(sol_N, 'steps', 10)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!