Professional Documents
Culture Documents
INITIAL CONDITIONS
ODE Problem: 𝑦 𝑡 = −0.1𝑦 𝑡 + 100𝑒 −0.1𝑡
A range of Initial Conditions is specified (ICs):
SEPARATION OF VARIABLES
Use separation of variables to solve the following problem for 𝑡
≥ 0.
𝑥 + 2𝑥 = 0, 𝑥 0 =3
Solution
𝑑𝑥
= −2𝑥
𝑑𝑡
𝑥(𝑡) 𝑡
𝑑𝑥
= −2 𝑑𝑡
3 𝑥 0
ln 𝑥(𝑡) − ln 3 = −2𝑡
𝑥 𝑡 = 3𝑒 −2𝑡
MATLAB Code
t=linspace(0,10,100);
Fun1=@(t,x) -2*x;
y=ode45(Fun1,t,3);
hold on
plot(y.x,y.y)
plot(t,3*exp(-2*t),'r--')
grid on
xlabel('t(s)');
ylabel('x(t)');
SEPARATION OF VARIABLES
Use separation of variables to solve the following problem for 𝑡
≥ 0.
𝑥 + 2𝑥 = 20, 𝑥 0 =3
Solution
𝑥 𝑡 = 10 − 7𝑒 −2𝑡
MATLAB Code
t=linspace(0,10,100);
Fun1=@(t,x) -2*x+20;
y=ode45(Fun1,t,3);
hold on
plot(y.x,y.y)
plot(t,10-7*exp(-2*t),'r--')
grid on
xlabel('t(s)');
ylabel('x(t)');
MATLAB Code
t=linspace(0,10,100);
Fun1=@(t,y) [y(2);y(1)-2*y(2)];
[t,y]=ode45(Fun1,t,[0;-1]);
hold on
plot(t,y(:,1))
plot(t,-sqrt(2)/4*exp((-
1+sqrt(2))*t)+sqrt(2)/4*exp((-1-
sqrt(2))*t),'r--')
grid on
xlabel('t(s)');
ylabel('x(t)');
Using
𝑒 𝑖𝜃 = cos 𝜃 + 𝑖 sin 𝜃
Get
𝑥 𝑡 = 𝑐1 𝑒 𝛼𝑡 cos 𝛽𝑡 + 𝑖 sin 𝛽𝑡 + 𝑐2 𝑒 𝛼𝑡 (cos 𝛽𝑡 − 𝑖 sin 𝛽𝑡)
𝑦 𝑡 = 2𝑒 −𝑡 sin 𝑡
MATLAB Code
t=linspace(0,10,100);
Fun1=@(t,y) [y(2);-2*y(1)-
2*y(2)];
[t,y]=ode45(Fun1,t,[0;2]);
hold on
plot(t,y(:,1))
plot(t,2*exp(-t).*sin(t),'r--')
grid on
xlabel('t(s)');
ylabel('x(t)');