Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this computer lab, we shall learn how to use MATLAB to obtain numerical solutions ( approximate solutions found through algorithms ) of 1 st

In this computer lab, we shall learn how to use MATLAB to obtain numerical solutions (approximate solutions found through algorithms) of 1st-order equations of the form y'=f(t,y)
1st-ORDER EQUATIONS.
MATLAB has several numerical procedures for computing the solutions of first-order equations and systems of the form y'=f(t,y); we shall concentrate on "ode 45", which is a souped-up Runge-Kutta method. The first step is to enter the equation by creating an "M-file" which contains the definition of your equation, and is given a name for reference, such as "diffeqn" (the suffix ".m" will be added to identify it as an M-file.). The second step is to apply ode 45 by using the syntax:
where t0 is the initial time, tf is the final time, and y0 is the initial condition, y(t0)=y0. The same syntax (1) works for equations and systems alike.
Example 1.y'=y2-t,y(0)=0, for 0t4
Creating the M-file. Start up MATLAB; the Command Window appears with the prompt > awaiting instructions. Choose New from the File menu and select M-file. You are now in a text editor where you create MATLAB files. Enter the following text:
function ypr=example1(t,y)
ypr=y???2-t;
Name this M-file "example1.m" by selecting Save As from the File menu. Note: The semicolon at the end tells MATLAB to suppress displaying output. (If you leave out the semicolon and run ode 45, MATLAB will display a lot of calculations that you don't need to see.)
2. Running ode45. Return to the Command Window, and enter the following:
[t,y]=ode45('example1',[0,4],0);
The 0,4 tells MATLAB to consider 0t4 and the last 0 tells it to start at y=0. When you hit the enter key, MATLAB will do its computing, then give you another promnt
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions