Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write MATLAB scripts to solve differential equations. Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle Objective: Write MATLAB scripts to solve differential equations. Implementation:

write MATLAB scripts to solve differential equations.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Computing 1: ELE1053 Project 3E:Solving Differential Equations Project Principle Objective: Write MATLAB scripts to solve differential equations. Implementation: MatLab is an ideal environment for solving differential equations. Differential equations are a vital tool used by engineers to model, study and make predictions about the behavior of complex systems. It not only allows you to solve complex equations and systems of equations it also allows you to easily present the solutions in graphical form. You will study the analytical solutions of DEs in your Mathematics module. This project consists of two parts: 1) Follow the instructions below to construct MatLab scripts to solve a range of ordinary differential equation and systems of equations. 2) Using the techniques in part 1) as an example apply the same approach to obtain and graph the solutions of some other problems. You have already studied how to plot functions in MatLab refer to your solutions to the MatLab exercises you did during the start of the course. Part 1: Exercise 1: Solve this differential equation. dy = ty dt First, represent y by using syms to create the symbolic function y(t). syms y(t) Define the equation using == and represent differentiation using the diff function. ode = diff(y.t) ==t'y Note how you tell MatLab to code the derivatve term. Solve the equation using the 'dsolve" command, i.e. ySol(t) = dsolve(ode) wanced C-coursework-labo X Equations.pdf Note your answer here (notice that MatLabis able to solve the equation analytically: The constant C1 appears because no initial/boundary condition was specified. Solve the equation with the initial condition y(0) == 2. The dsolve function finds a value of C1 that satisfies the condition. cond = y(0) == 2; %3D ySol(t) = dsolve(ode,.cond) %3D Note your answer here and plot a graph of the solution y(t) against t. Use the MatLab fplot command (you have used the 'plot' command before to plot numerical data, the fplot' command does a similar thing for plotting functions'.) Use the MatLab 'help command or look up examples of using fplot' using an Internet search engine. fplot(ySol) Using the information you find change the interval over which the function is plotted to cover the interval for (t) of [-3,+3]. Save the graph in a file. Exercise 2: Solve the nonlinear differential equation: G+y)* = 1 Subject to the initial condition: y(0) = 0 Use Exercise 1 as an example of how to code the script. Save your script in a M file. Roughly sketch the solution over the range [-6,10] here: For all the remaining exercises save you scripts in .M files. Exercise 3: Solve the second order differential equation: d'y = cos(2x) - y dx? Subject to the boundary conditions: y(0) = 1 y (0) = 0 Follow these steps: Define the equation and conditions The second initial condition involves the first derivative of y.Represent the derivative by creating the symbolic function Dy = diff(y) and then define the condition using Dy(0)==0. The MatLab commands are very similar to the previous examples: syms y(x) Dy = diffly): ode = diffly,x,2) == cos(2"x)-y: cond1 = y(0) = 1; cond2 = Dy(0) == 0; Solve ode for y. Simplify the solution using the simplify function. conds = [cond1 cond2]: ySol(x) = dsolve(ode,conds); ySol - simplify(ySol) Plot the resulting solution YSol over the interval [-.]. Note again here that MatLab gives you an analytic solution and not just a numerical one. This is a powerful use of MatLab. Exercise 4: Solve a set of differential equations, e.g. a pair of differential equations that have to be solved simultaneously, movement in 2-dimensions parameterized by time. You can solve a system of several ordinary differential equations in several variables by using the 'dsolve' function, with or without initial conditions. Solve this system of two simultaneous linear first-order differential equations: du = 3u + 4v dt dv = -4u + 3v dt The solution approach is not dissimilar to the previous exercises in solving a single differential equation. First, represent u and v by using 'syms' to create the symbolic functions u(t) and v(t). syms u(t) v(t) Define the equations using == and represent differentiation using the diff function. ode1 = diff(u) == 3u + 4v; ode2 = diff(v) =n -4'u + 3*v; Combine the two equation into a vector: odes = [ode1; ode2] Solve the system using the 'dsolve' function. Store u(t) and v(t) directly by providing multiple output arguments: [uSal(t), vSol(t) = dsolve(odes) Note the answer here: The constants C1 and C2 appear because no conditions are specified. Now solve the system with the initial conditions u(0) = 0 v(0) = 1 The dsolve function finds values for the constants that satisfy these conditions. cond1 = u(0) == 0; cond2 = v(0) == 1; conds = [cond1; cond2]: [uSol(t), vSol(t)) = dsolve(odes.conds) Visualize the solution using fplot fplot(uSol) hold on fplot(vSol) grid on legend('uSol, vSol", Location', 'best) 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 completedas examplesof how to solve differential equations, find the solutions to the following differential equations. Save each script in a M file and plot a graph of the solution. Problem 1 Solve the following differential equation subject to the give boundary conditions: d'y = cos(2x) - y dx Subject to the boundary conditions: y(0) = 1 y(2) -5 Problem 2 Solve the following differential equation subject to the give boundary conditions. dr Subject to the boundary conditions: u(0) = 1 u'(0) = -1 "(0) Problem 3 Solve the following differential equation subject to the give initial conditions. dx x(0) --2 +2' di Problem 4 Solve the following differential equation subject to the give initial conditions. dr 41nt x(1) - 0 dr Problem 5 Solve the following differential equation subject to the give initial conditions. -r+x*, x(1) - 4 di Problem 6 Solve the following differential equation subject to the give initial conditions. dx - le dr + x2, x(1) - 2 Problem 7 Solve the following differential equation subject to the give initial conditions. dx 1- 2x = 4t +e', x(1) = 0 dt Problem 8 Solve the following differential equation subject to the give initial conditions. de + 3x - 0, x(0) -1, de 2. dr (0) = 0 dt dr Problem 9 Solve the following differential equation subject to the give initial conditions. dx + 12+ 8x = 0 di x(1) = 1. (1) 1, (0)- dr Problem 10 Solve the following differential equation subject to the give initial conditions. de + 2. dt +x- 4 cos 21, x(0) 0, (0) - 2 dr Problem 11 Solve the following differential equation subject to the give initial conditions. 174 + 13x - 1, x(0)- 1, + 17 dr dt 0) - 1.0)- di Problem 12 Solve the following differential equation in analytic form. (Do not graph the result.) d'x dx + 4x cos 4r-2 sin 41 di dr Write your solution here: When you have completed all the exercise and had them checked by a demonstrator, who will record that it worksZIP up the script files (.m) and upload the ZIP archive to QoL

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

ABACUS Company uses activity based

Answered: 1 week ago

Question

5. Describe how contexts affect listening

Answered: 1 week ago