본문 바로가기
지식공학/Matlab

Matlab 1차 미분방정식 풀이 (문제와 코드 공개)

by Eric87 2020. 11. 10.
반응형

Q 유량

A tank contains 400 gal of brine in which 100 lb of salt are dissolved. Fresh water runs into the tank at a rate of 2 gal/min. The mixture, kept practically uniform by stirring, runs out at the same rate. How much salt will there be in the tank at the end of 1 hour?

Sol) 물탱크안에 100lb의 소금이 용해되어 있고 분당 2gal의 물이 유입되고 충분히 혼합되고 같은 유량이 빠져나간다. 분당 소금의 흐름을 y라고 하면 소금의 양은 시간에 따라 결정된다. 

$$y'(t) = 0 - \frac{2}{400}y$$

위 식을 시간 t에 대해 미분방정식을 풀면 된다.

$$\frac{dy}{y}=-0.005dt\\\ln{y}=-0.005t+c$$

따라서 소금의 양은 

$$y=e^{-0.005t+c}=ce^{-0.005t}$$

이때 초기 소금의 양은 100lb이므로 t=0을 대입하면 c의 값을 구할 수 있다. c=100

$$ y=100e^{-0.005t} $$

위 식을 매틀랩으로 풀면 다음과 같다.

>> syms y(t)
eqn=diff(y)==0-2/400*y;
cond=y(0)==100;
s=dsolve(eqn,cond)
 
s =
 
100*exp(-t/200)

 

한시간 후 소금의 양을 구하기 위해서 t=60을 대입하면 74.0818lb값을 얻을 수 있다. 그래프는 다음과 같다.

 


Q Newton’s law of cooling.

A thermometer, reading 5° C, is brought into a room whose temperature is 22° C. One minute later the thermometer reading is 12° C. How long does it take until the reading is practically 22°C , say, 21.9°C ?

Sol) 초기 온도는 5도이고, 시간에 따라 온도가 일정한 비율로 상승을 하고 방 온도에 수렴할 것이다. 일정한 비율을 k라고 하면 다음과 같이 미분방정식을 세울 수 있다.

$$T'=k(T-22)\\\frac{dT}{T-22}=kdt$$

위 식을 적분하여 일반 해를 풀면

$$\ln{T-22}=kt+c,\qquad T=22+ce^{kt}$$

초기 온도가 5도 이므로 t=0을 대입해서 c의 값을 구할 수 있다. c=-17. 1분 후에 12도라고 했으므로 다시 t=60을 대입하여 k값을 구하면 k=-0.0088. 따라서 특수 해는

$$ T=22-17e^{-0.0088t} $$

온도가 21.9도가 되는 시간을 구하면 약 583초가 나온다. 위 식의 바탕으로 매틀랩을 활용하여 문제를 풀면 다음과 같다.

>> syms T(t) k
eqn=diff(T)==k*(T-22);
cond=T(0)==5;
s=dsolve(eqn,cond)
 
s =
 
22 - 17*exp(k*t)
>> solve(s==12,k) #1분 후 k값을 풀기 위한 명령 
 
ans =
 
log(10/17)/t
>> log(10/17)/60


ans =

   -0.0088 		# k값
>>sol=22 - 17*exp(-0.0088*t)
>> solve(sol==21.9,t)
 
ans =
 
(1250*log(170))/11
 
>> (1250*log(170))/11


ans =

  583.6135


Q Dryer.

If a wet sheet in a dryer loses its moisture at a rate proportional to its moisture content, and if it loses half of its moisture during the first 10 min of drying, when will it be practically dry, say, when will it have lost 99% of its moisture? First guess, then calculate.

Sol) 습기가 일정한 비율을 가지고 사라지므로 미분방정식은 다음과 같다.

$$ y'=ky \qquad \frac{dy}{y}=kdt\\y=y_0 e^{kt}$$

초기 습기을 1으로 간주하고 t=10분 후 습기가 처음의 반이 사라지므로 0.5라고 할 수 있다. 이때 k의 값을 구하면 k=-0.0693. 따라서 특수해는 다음과 같다.

$$y=y_0 e^{-0.0693t}$$ 

99% 습기가 사라지만 1%만 남기 때문에 

$$\frac{1}{100}=y_0 e^{-0.0693t}$$

이때 시간을 구하면 된다. 약 66.4분 후 습도 99%가 증발된다.

>> syms y(t) k
>> eqn = diff(y)==k*y;
>> cond=y(0)==1;
>> s=dsolve(eqn,cond)
 
s =
 
exp(k*t)
>> solve(s==0.5,k)
 
ans =
 
-log(2)/t
 
>> -log(2)/10


ans =

   -0.0693
>> sol=exp(-0.0693*t);
>> solve(sol==0.01,t)
 
ans =
 
(20000*log(10))/693
 
>> (20000*log(10))/693


ans =

   66.4527

 


Q Rocket.

A rocket is shot straight up from the earth, with a net acceleration ( acceleration by the rocket engine minus gravitational pullback) of 7t m/sec^2 during the initial stage of flight until the engine cut out at t=10sec. How high will it go, air resistance neglected?

Sol) 가속도를 생각하면 문제에서 7t로 주어져 있고 로켓은 중력 g를 받고 있으므로 가속도 a는 다음과 같다.

$$\frac{d^2y}{d^2t} = a = 7t-g\\\frac{dy}{dt} = 7/2t^2-gt+c$$

초기 속도는 0이므로 c=0이다. 위 식을 다시 적분하면 거리가 나오므로

$$y=7/6t^3-g/2t^2+c$$

초기 거리 또한 0이므로 c=0. 10초 후 거리는 677m가 나온다.

syms y(t) g
eqn=diff(y,2)==7*t-g;
cond=diff(y(0))==0;
cond2=y(0)==0;
s=dsolve(eqn,cond,cond2)
 
s =
 
(t*(7*t^2 - 3*g*t + C1))/6

Q Friction. If a body slides on a surface, it experiences friction F (a force against the direction of motion). Experiments show that lFl=ulNl (Coulomb’ s6 law of kinetic friction without lubrication), where N is the normal force (force that holds the two surfaces together; see Fig) and the constant of proportionality u is called the coefficient of kinetic friction. In Fig assume that the body weighs 45 nt (about 10 lb; see front cover for conversion). u=0.2 (corresponding to steel on steel), a=30 degree, the slide is 10 m long, the initial velocity is zero, and air resistance is negligible. Find the velocity of the body at the end of the slide.

Sol) 중력에 의해 내려가는 가속도는 g*sin(a)가 된다. 마찰력은 진행 방향에 반대되므로 마찰력에 의해 가속도가 감소된다. 감소되는 가속도는 g*u*cos(a). g=9.81, u = 0.2, a=30이므로 

$$\frac{dv(t)}{dt} = g\sin{\alpha}-0.2g\cos{\alpha} = 3.203$$

따라서 속력은 다음과 같다.

$$v(t) = 3.203t,\qquad s(t) = 3.203/2t^2=1.6015t^2$$

거리 10m 움직였으므로 이때 걸리는 시간은 2.5 초이다. 이때 속력은 3.203*2.5 = 8.01 m/s.

 

반응형

댓글