Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to put frist order in MathLab 1.1 First Order Equations Though MATLAB is primarily a numerics package, it can certainly solve straightforward differential equations

image text in transcribed How to put frist order in MathLab
1.1 First Order Equations Though MATLAB is primarily a numerics package, it can certainly solve straightforward differential equations symbolically. Suppose, for example, that we want to solve the first order differential equation y'(r) = ry. We can use MATLAB's built-in dsolve(). The input and output for solving this problem in MATLAB is given below. >>y = dsolve('Dy = y*x','x') y = CI 'exp(1/2*x^2) Notice in particular that MATLAB uses capital D to indicate the derivative and requires that the entire equation appear in single quotes. MATLAB takes t to be the independent variable by default, so here a must be explicitly specified as the independent variable. Alternatively if you are going to use the same equation a number of times, you might choose to define it as a variable, say, egn1 must be explicitly s >>y dsolve(eqnl,x') y = C1 'exp(1/2*x^2) To solve an initial value problem, say, equation (1.1) with y(l) -1, use >>y = dsolve(eqnl/y(1)=1','x') 1/expl 1/2)"exp(1/2*x^ 2) or >>inits 'y(1)=1'; > >y dsolve(eqnl ,inits,'x') 1/exp(1/2)"exp(1/2*x 2) Now that we've solved the ODE, suppose we want to plot the solution to get a rough idea of its behavior. We run immediately into two minor difficulties: (1) our expression for y(a) isn't suited for array operations (", /,."), and (2) y, as MATLAB returns it, is actually a symbol (a symbolic object). The first of these obstacles is straightforward to fix, using ter tone For the second, we employ the useful command eval(), which evaluates or executes text strings that constitute valid MATLAB commands. Hence, we can use

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