Code for solving first-order ode with symbolic initial condition
15 views (last 30 days)
I am very new to MATLAB, and writing MATLAB code for solving the problem #20 of Section 1.1 in Kreyszig (2011).
Problem #20 is as follows:
Exponentialdecay. Subsonicflight. The efficiency of the engines of subsonic airplanes depends on air pressure and is usually maximum near 35,000 ft. Find the air pressure at this height. Physical information. The rate of change is proportional to the pressure. At 18,000 ft it is half its value at sea level.
I wrote the following code for solving the problem, but get a wrong answer.
syms y(t) k
ode = diff(y) == k*y
cond = y(18000) == y(0)/2
ySol(t) = dsolve(ode, cond)
I got a trivial solution.
How to get a non-trivial solution of this problem?
If I solve the problem with pencil and eraser, the non-trivial solution is .
Torsten on 25 Nov 2022
Edited: Torsten on 25 Nov 2022
syms y(h) k
ode = diff(y) == k*y;
sol_ode_general = dsolve(ode)
vars = symvar(sol_ode_general)
eqn1 = subs(sol_ode_general,vars(2),0) == 1.013e5; %pressure in Pa, distance in m
eqn2 = subs(sol_ode_general,vars(2),18000*0.3048) == 1.013e5/2; %pressure in Pa, distance in m
[sol.C_1 sol.k] = solve([eqn1,eqn2],[vars(1),vars(3)]);
sol_ode_specific = subs(sol_ode_general,[vars(1) vars(3)],[sol.C_1,sol.k])
Pressure_at_36000_feet = subs(sol_ode_specific,vars(2),36000*0.3048) % pressure in Pa, distance in m