sol_tau =
Solving boundary value problem
Afficher commentaires plus anciens
Hi,
I am trying to solve the following differential equation in MATLAB and obtain tau-c vs x curve when Beta^2= 0.048. My code is attached at the end of the snapshot. I am getting error when I introduce the integration boundary condition.

Any sort of help or guidance is highly appreciated.
Thanks.
Réponses (1)
I think this is what you want. But although there are four boundary conditions for four free parameters, they do not suffice to fix a unique solution. Thus there must be an additional condition missing.
syms To(x) Ti(x) tau(x)
syms beta c tau_avg
% Define ODE system and boundary conditions
eqns = [diff(To,x)+tau==0,diff(Ti,x)-2*tau==0,diff(tau,x,2)-beta^2*tau==0];
conds = [To(-c) == 2*c*tau_avg,Ti(-c) == 0, To(c) == 0, Ti(c) == 4*c*tau_avg];
% Compute solution of ODE system with boundary conditions
sol = dsolve(eqns,conds);
sol_tau = simplify(sol.tau)
% Write solution for tau in basis functions sinh(beta*x) and cosh(beta*x)
syms A B
eqn = sol_tau == A*sinh(beta*x)+B*cosh(beta*x);
coeffs = solve([subs(eqn,x,c),subs(eqn,x,-c)],[A,B]);
coeffs.A = simplify(coeffs.A);
coeffs.B = simplify(coeffs.B);
sol_tau = coeffs.A*sinh(beta*x) + coeffs.B*cosh(beta*x)
v4 = symvar(sol_tau)
% Choose numerical values for beta, tau_avg, c and the free paramter C1 and substitute
% in solution for tau
beta_num = sqrt(0.048);
tau_avg_num = 0.25;
c_num = 1;
C1_num = 0;
sol_tau_num = subs(sol_tau,[beta tau_avg c v4(1)],[beta_num tau_avg_num c_num C1_num])
% Plot solution for tau
fplot(sol_tau_num,[-c_num c_num]) % plot tau_c
3 commentaires
Sumit
le 16 Juil 2025
Maybe you couldn't understand it from the code: the conditions
T(-c)==0, T(c)==2*c*tau_avg
for the newly defined function T implement
integral_{-c}^{c} tau(x) dx = T(c) - T(-c) = 2*c*tau_avg - 0 = 2*c*tau_avg
, thus the boundary condition you want to set.
syms tau(x) T(x)
syms beta tau_avg c
eqns = [diff(tau,x,2)-beta^2*tau==0,diff(T,x)-tau==0];
conds = [T(-c)==0,T(c)==2*c*tau_avg];
sol = dsolve(eqns,conds)
simplify(sol.tau)
Catégories
En savoir plus sur Equation Solving dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


