Question
write MATLAB scripts to solve differential equations.

Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle Objective: Write MATLAB scripts to solve dif
wanced C-coursework-labo X Equations.pdf Note your answer here (notice that MatLabis able to solve the equation analytically:
For all the remaining exercises save you scripts in .M files. Exercise 3: Solve the second order differential equation: dy =
The solution approach is not dissimilar to the previous exercises in solving a single differential equation. First, represent
Make sure you store your code in a script file and keep a copy of the image. Part 2: Using the Part 1 exercises you have comp
Problem 8 Solve the following differential equation subject to the give initial conditions. de + 3x - 0, x(0) -1, de 2. dr (0
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Exercise 1)

Code:

%Exercise 1
syms y(t)

ode = diff(y,t)==t*y;
%Showing this output
ySol(t)= dsolve(ode)

%Using boundary condition
cond = y(0)==2;

%Showing this output
ySol(t)= dsolve(ode,cond)

%Plting on a interval of [-3,+3]
fplot(ySol,[-3,3]);

PLOT:

180 160 140 120 100

Exercise 2) :

Code:

%Exercise 2
syms y(t)

ode = (diff(y,t)+y)^2==1;

%Using boundary condition
cond = y(0)==0;

%Showing this output
ySol(t)= dsolve(ode,cond)

%Plting on a interval of [-6,+10]
fplot(ySol,[-6,10]);

Plot:

Exercise 2) :

Code:

Plot:

-300 -400 6 4 -2 0 2 4 6 8 10

Exercise 3) :

Code:

%Exercise 3
syms y(x)
%1st Differential
Dy = diff(y);

%original equation
ode = diff(y,x,2)==cos(2*x)-y;

%Using boundary condition
cond1 = y(0)==1;
cond2 = Dy(0)==0;

conds = [cond1,cond2];

%Solving equation using 'conds' as condition
ySol(x)= dsolve(ode,conds)

ySol = simplify(ySol)
%Polting on an assumed interval of [-6,+10]
fplot(ySol,[-6,10]);

Plot:

0.5 -0.5 | 6 4 20 24 68 10

Exercise 4) :

Solution 1

uSol(t) =

C10*cos(4*t)*exp(3*t) + C9*sin(4*t)*exp(3*t)


vSol(t) =

C9*cos(4*t)*exp(3*t) - C10*sin(4*t)*exp(3*t)

Code:

%Exercise 4
syms u(t) v(t)
%1st Differential
ode1 = diff(u)==3*u+4*v;
%2nd Differential
ode2 = diff(v) == -4*u+3*v;
%original equation
odes = [ode1,ode2];
%Solving Without boundary condition
[uSol(t),vSol(t)]=dsolve(odes)


%Using boundary condition
cond1 = u(0)==0;
cond2 = v(0)==1;

conds = [cond1,cond2];

%Solving equation using 'conds' as condition
[uSol(t),vSol(t)]= dsolve(odes,conds)


%Polting with default range
fplot(uSol);
hold on
fplot(vSol);
grid on
legend('uSol','vSol','Location','best')

Plot:

3,106 USol v Sol 1.5 -0.5 L -5 4 -3 -2 -1 0 1 2 3 4 5

Problem 1) :

Solution:

ySol(x) =

(5*cos(x))/3 + sin(x)*(sin(3*x)/6 + sin(x)/2) - (2*cos(x)*(6*tan(x/2)^2 - 3*tan(x/2)^4 + 1))/(3*(tan(x/2)^2 + 1)^3) - (sin(x)*(6*cos(2) + 9*sin(2)^2*tan(1)^2 + 9*sin(2)^2*tan(1)^4 + 3*sin(2)^2*tan(1)^6 + sin(2)*sin(6) + 6*cos(2)*tan(1)^2 + 42*cos(2)*tan(1)^4 + 10*cos(2)*tan(1)^6 + 3*sin(2)^2 - 90*tan(1)^2 - 90*tan(1)^4 - 30*tan(1)^6 + 3*sin(2)*sin(6)*tan(1)^2 + 3*sin(2)*sin(6)*tan(1)^4 + sin(2)*sin(6)*tan(1)^6 - 30))/(6*sin(2)*(tan(1)^2 + 1)^3)

Code:

%Problem 1
syms y(x)
% Differential
Dy = diff(y);
%original Differential
ode = diff(y,x,2) == cos(2*x)-y;

%Using boundary condition
cond1 = y(0)==1;
cond2 = y(2)==5;

conds = [cond1,cond2];

%Solving equation using 'conds' as condition
ySol(x) = dsolve(ode,conds)


%Polting with default range
fplot(ySol);

Plot:

5 4 3 2 1 0 1 2 3 4 5

Problem 2) :

SOlution:

uSol(x) =

(pi*exp(x))/3 - exp(-x/2)*cos((3^(1/2)*x)/2)*(pi/3 - 1) - (3^(1/2)*exp(-x/2)*sin((3^(1/2)*x)/2)*(pi + 1))/3

Code:

%Problem 2
syms u(x)
% Differential
Du1 = diff(u);
Du2 = diff(Du1);
%original Differential
ode = diff(u,x,3) == u;

%Using boundary condition
cond1 = u(0)==1;
cond2 = Du1(0)==-1;
cond3 = Du2(0) ==pi;

conds = [cond1,cond2,cond3];

%Solving equation using 'conds' as condition
uSol(x) = dsolve(ode,conds)


%Polting with default range
fplot(uSol);

Plot:

-5 -4 -3 -2 -1 0 1 2 3 4

Problem 3) :

SOlution:

xSol(t) =

2^(1/2)*((t*(t^2 - 3))/3)^(1/2) - 2
- 2^(1/2)*((t*(t^2 - 3))/3)^(1/2) - 2

Code:

%Problem 3
syms x(t)

%original Differential
ode = diff(x,t) == (t^2-1)/(x+2);

%Using boundary condition
cond = x(0)==-2;

%Solving equation using 'cond' as condition
xSol(t) = dsolve(ode,cond)


%Polting with default range
fplot(xSol);

Plot:

s_ _ £_ _ - -- ----- -- --- - -- ----- -- --- - 。 :

Problem 4) :

SOlution:


xSol(t) =

3^(1/3)*(4*t*(log(t) - 1) + 4)^(1/3)
3^(1/3)*((3^(1/2)*1i)/2 - 1/2)*(4*t*(log(t) - 1) + 4)^(1/3)
-3^(1/3)*((3^(1/2)*1i)/2 + 1/2)*(4*t*(log(t) - 1) + 4)^(1/3)

Code:

%Problem 4
syms x(t)

%original Differential
ode = diff(x,t) == 4*log(t)/x^2;

%Using boundary condition
cond = x(1)==0;

%Solving equation using 'cond' as condition
xSol(t) = dsolve(ode,cond)


%Polting with default range
fplot(xSol);

Plot:

- - - - - - - - - - - : -- - ター 1 .5 2 2.5_ 3_ 3.5 4 4.5 5

Problem 5) :

Solution:


xSol(t) =

4^(1/4)*t*(log(t) + 64)^(1/4)

Code:

%Problem 5
syms x(t)

%original Differential
ode = (x^3)*t*diff(x,t) == t^4+x^4;

%Using boundary condition
cond = x(1)==4;

%Solving equation using 'cond' as condition
xSol(t) = dsolve(ode,cond)


%Polting with default range
fplot(xSol);

Plot:

10.5 1 1.5 2 2.5 3 3.5 4 4. 5 5

Problem 6) :

EQUATION IS VERY BLURRY. UNABLE TO COMPREHEND WHAT'S WRITTEN IN EXPONENTIAL.

Kindly Comment correct Equation, I will give you the code for it.

Problem 7) :

UNABLE TO UNDERSTAND WHAT'S WRITTEN IN THE EXPONENTIAL.

USING THIS GUESSED EQUATION:

da 1– 2x -= 4ttet dtt z(1) = 0

Solution:

xSol(t) =

(2*exp(t) + t^2*exp(t) - 2*t*exp(t) + t^2/2 + t^4)/t^2 - (exp(1) + 3/2)/t^2

Code:

%Problem 7
syms x(t)

%original Differential
ode = diff(x,t)-(1-2*x)/(t) == 4*t+exp(t);

%Using boundary condition
cond = x(1)==0;

%Solving equation using 'cond' as condition
xSol(t) = dsolve(ode,cond)


%Polting with default range
fplot(xSol);

Plot:

- - - - - - - - - - - - - - - - - - - - - - - - - - 432 10 1 2 3 --150 --200F

Problem 8) :

Solution:


xSol(t) =

exp(t/2)*cos((5^(1/2)*t)/2) - (5^(1/2)*exp(t/2)*sin((5^(1/2)*t)/2))/5

Code:

%Problem 8
syms x(t)
%Differntial 1
Dx =diff(x);
%original Differential
ode = 2*diff(x,t,2)-2*Dx +3*x==0;

%Using boundary condition
cond1 = x(0)==1;
cond2 = Dx(0)==0;

conds=[cond1,cond2];

%Solving equation using 'conds' as condition
xSol(t) = dsolve(ode,conds)


%Polting with default range
fplot(xSol);

Plot:

| 5 4 3 2 4 0 1 2 3 4 5

Problem 9) :

Solution:


xSol(t) =

2*exp(-2*t)*exp(2) - 5*t*exp(-2*t)*exp(2) + 4*t^2*exp(-2*t)*exp(2)

Code:

%Problem 9
syms x(t)
%Differntial 1
Dx1 =diff(x);
Dx2 = diff(Dx1);
%original Differential
ode = diff(x,t,3)+6*Dx2 +12*Dx1+8*x==0;

%Using boundary condition
cond1 = x(1)==1;
cond2 = Dx1(1)==1;
cond3 = Dx2(1)==0;
conds=[cond1,cond2,cond3];

%Solving equation using 'conds' as condition
xSol(t) = dsolve(ode,conds)


%Polting with default range
fplot(xSol);

Plot:

X 107 5 4 -3 -2 -1 0 1 2 3 4 5

Problem 10) :

Solution:


xSol(t) =

(12*exp(-t))/25 - (4*cos(2*t + atan(4/3)))/5 + t*exp(-t)*((4*cos(atan(4/3) + 2)*exp(1))/5 - 12/25)

Code:

%Problem 10
syms x(t)
%Differntial 1
Dx =diff(x);

%original Differential
ode = diff(x,t,2)+2*Dx +x==4*cos(2*t);

%Using boundary condition
cond1 = x(0)==0;
cond2 = Dx(0)==2;

conds=[cond1,cond];

%Solving equation using 'conds' as condition
xSol(t) = dsolve(ode,conds)


%Polting with default range
fplot(xSol);

Plot:

2000 1800 1600 1400 1200 1000 아 800 600 400 아 200 1 5 4 3 2 -1 0 1 2 3 4 5

Problem 11) :

Solution:


xSol(t) =

(8*exp(-t))/5 - (44*cos(3*t)*exp(-2*t))/65 + (27*sin(3*t)*exp(-2*t))/65 + 1/13

Code:

%Problem 11
syms x(t)
%Differntial 1
Dx1 =diff(x);
Dx2 = diff(Dx1);
%original Differential
ode = diff(x,t,3)+5*Dx2 +17*Dx1+13*x==1;

%Using boundary condition
cond1 = x(0)==1;
cond2 = Dx1(0)==1;
cond3 = Dx2(0)==0;
conds=[cond1,cond2,cond3];

%Solving equation using 'conds' as condition
xSol(t) = dsolve(ode,conds)


%Polting with default range
fplot(xSol);

Plot:

4000 上 2000 -2000 -4000 -6000 - 5 4 -3 -2 - 1 0 1 2 3 4 5

Problem 12) :

Solution:


xSol(t) =

sin((7^(1/2)*t)/2)*(cos(4*t - (7^(1/2)*t)/2)/48 - cos(4*t + (7^(1/2)*t)/2)/48 + sin(4*t - (7^(1/2)*t)/2)/16 - sin(4*t + (7^(1/2)*t)/2)/16 + (17*7^(1/2)*cos(4*t - (7^(1/2)*t)/2))/336 + (17*7^(1/2)*cos(4*t + (7^(1/2)*t)/2))/336 + (7^(1/2)*sin(4*t - (7^(1/2)*t)/2))/16 + (7^(1/2)*sin(4*t + (7^(1/2)*t)/2))/16) - cos((7^(1/2)*t)/2)*(cos(4*t - (7^(1/2)*t)/2)/16 + cos(4*t + (7^(1/2)*t)/2)/16 - sin(4*t - (7^(1/2)*t)/2)/48 - sin(4*t + (7^(1/2)*t)/2)/48 + (7^(1/2)*cos(4*t - (7^(1/2)*t)/2))/16 - (7^(1/2)*cos(4*t + (7^(1/2)*t)/2))/16 - (17*7^(1/2)*sin(4*t - (7^(1/2)*t)/2))/336 + (17*7^(1/2)*sin(4*t + (7^(1/2)*t)/2))/336) + C3*exp((3*t)/2)*cos((7^(1/2)*t)/2) - C4*exp((3*t)/2)*sin((7^(1/2)*t)/2)

Code:

%Problem 12
syms x(t)
%Differntial 1
Dx =diff(x);

%original Differential
ode = diff(x,t,2)-3*Dx+4*x==cos(4*t)-2*sin(4*t);

%Solving equation without Conditions
xSol(t) = dsolve(ode)

Add a comment
Know the answer?
Add Answer to:
write MATLAB scripts to solve differential equations. Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT