Question

Need help using Matlab to solve differential equations, will rate! Thank You!

a) The code used to solve each problem b) The output form c) Use EZPLOT (where possible) to graph the result Use Matlab symbolic capabilities to solve the following Differential Equations: yy +36x = 0 3. ytky = e2kakis a constant y +(x +1)y = exy ;y(0) = 0.5 4 4y-20y+25y = 0 xy-7x/+16y=0 xy-2xy+2y=x cos(x) yy =292 y-4y+4y = (x + 1)e 2x

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find following MATLAB code, ouput and the Ezplot (wherever possible) for all parts. We have used dsolve() function in MATLAB to solve Symbolic solution of ordinary differential equations.

Part 1:

MATLAB Code:

% Part 1
syms y(x)
ode = diff(y,x)*y == -36*x % diffrential equation to be solved
ySol(x) = dsolve(ode) % solve the function

The screenshot of the result:

Command Window ode (x) - y (x) *diff (y (x) , x) --36#x 2 (1/2)18*x2 C2) (1/2)

PART 2:

MATLAB Code:

% Part 2
syms y(x)
ode = exp(2*x)*diff(y,x) == 2*(x+2)*y^3 % diffrential equation to be solved
cond = y(0) == 1/sqrt(5); % set the initial condition
ySol(x) = dsolve(ode,cond) % solve the function
ezplot(ySol(x)) % plot the solution

-----------------------SAMPLE OUTPUT

Command Window ode (x) exp (2*x) *diff (y(x), x) y(x) 3* (2*x 4) ySOI (x) (2 (1/2)((2*exp (2*x)) (2*x 5)) 1 (1/2))/2(21/2 (2 exp(2 x))/(2 x +5))1212 80 70 60 50 40 30 20 10 0 -2 6

PART 3:

MATLAB Code:

% Part 3
syms y(x)
k=10; % value asssigned to constant
ode = diff(y,x)+k*y == exp(2*k*x) % diffrential equation to be solved
ySol(x) = dsolve(ode) % solve the function
ezplot(ySol(x))

----------------------------------SAMPLE OUTPUT

Command Window ode (x) - 10*y(x) + diff (y (x), x) -exp (20*x) exp (20*x)/30 + C1*exp (-10*x)

exp(20 x)130+C, exp(-10 x) 4 -2 -4 -6 -2 6

PART 4:

MATLAB Code:

% Part 4
syms y(x)
ode = diff(y,x)*((x+1)*y) == exp(x^2)*y^3 % diffrential equation to be solved
cond = y(0) == 0.5; % initial condition set
ySol(x) = dsolve(ode,cond) % solve the function

------------------------------------SAMPLE OUTPUT

Command Window ode (x)- y (x)diff (y(x), x)( 1)exp (x*2) *y (x)3 -1/ (int (exp (y2 ) / (y + 1), y, 0, x, IgnoreSpecialCases

Note that ySol(x) here indicates that the result obtained here has been evaluated through special cases, the details of which have been mentioned along with.

PART 5:

% Part 5
syms y(x)
ode = diff(y,x)+y == x % diffrential equation to be solved
cond = y(0) == 4; % initial condition set
ySol(x) = dsolve(ode,cond) % solve the function
ezplot(ySol(x)) % plot the solution obtained

---------------------------------SAMPLE OUTPUT:

Command Window ode (x) diff (y (x), x) + y(x) x ySOI(x) = x 5*exp (-x)1

x + 5 exp(-x) 1 1000 900 800 700 600 500 400 300 200 100 -2

PART 6:

MATLAB CODE:

% Part 6
syms y(x)
ode = 4*diff(diff(y,x),x)-20*diff(y,x)+25*y == 0 % diffrential equation to be solved
ySol(x) = dsolve(ode) % solve the function

-------------------SAMPLE OUTPUT:

ode (x) 25*y (x) -20*diff (y (x), x) + 4*diff (y (x), Х, x) -0 ySol (x) c1 * expl (5*x) /2 ) + C2*Xexp ((s*x)/2)

PART 7:

MATLAB CODE:

% Part 7
syms y(x)
ode = diff(diff(y,x),x)-diff(y,x)+y == 2*sin(3*x) % diffrential equation to be solved
ySol(x) = dsolve(ode) % solve the function

--------------------------------SAMPLE OUTPUT:

ode (x) y(x) -diff (y (x), x) + diff (y(x), Х, x) -- 2*sin ( 3 *x) cos ( (3 (1/2) x)/2) (3 cos (3x- (3 (1/2)*)/2)73(3*cos (3x

PART 8:

MATLAB Code:

% Part 8
syms y(x)
ode = x^2*diff(diff(y,x),x)-7*x*diff(y,x)+16*y == 0 % diffrential equation to be solved
ySol(x) = dsolve(ode) % solve the function

----------------------------------SAMPLE OUTPUT:

Command Window ode (x) = 16*y (x) x 2 diff (y(x), x, x) - 7*x*diff (y (x), x) 0

PART 9:

MATLAB CODE:

% Part 9
syms y(x)
ode = x^2*diff(diff(y,x),x)-2*x*diff(y,x)+2*y == x^3*cos(x) % diffrential equation to be solved
ySol(x) = dsolve(ode) % solve the function

-----------------------------SAMPLE OUTPUT:

Command Window ode (x) - 2*y(x)+ x 2 diff (y (x), x, x) - 2*x*diff (y (x), x) x*3*cos (x) yS01 (x) C1*x x*2*sin (x) C2*x*2 -

PART 10:

MATLAB CODE:

% % Part 10
syms y(x)
ode = y*diff(diff(y,x),x) == 2*diff(y,x)^2 % diffrential equation to be solved
ySol(x) = dsolve(ode) % solve the function

------------------------------------------------SAMPLE OUTPUT

Command Window y (x) *diff (y (x), X, X) -2 * diff (y(x) , x) ^2 ySol (x) = С5 -1/ (C3 C1*x)

PART 11:

MATLAB Code:

% Part 11
syms y(x)
ode = diff(diff(y,x),x)-4*diff(y,x)+4*y == (x+1)*exp(2*x) % diffrential equation to be solved
ySol(x) = dsolve(ode) % solve the function

---------------------------------------SAMPLE OUTPUT

Command Window ode (x) 4*y (x) -4*diff (y (x), x) + diff (y (x), Х, x) -exp (2*x)* (x + 1) Sol (x) - CI * exp (2 *x) + (x^ 2

For more details regarding working, other examples and syntax information, please write 'help dsolve' in command window of MATLAB.

Add a comment
Know the answer?
Add Answer to:
Need help using Matlab to solve differential equations, will rate! Thank You! a) The code used...
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