eS
ordinary differential Bysstions (ODEs)
_- Many problems in sclence and. Angineering can be -formulated
Into ordinary differential Equations (DES).
— ODEs can he of @ Fivst-orew ODE and
P. ii) Second —order OPE «
Boia ie ele
gider ardinary differentia} duration {First otder QU,3
— at fs an Gqstion that contains the derivative ef the dependent
vartable »
the qeneral form af First-order ook 1s, &cpessed 95,
aa
de. tou | coe
cere Eenx fs independent variable
4 15 dependent variable.
@
= order evel ahi 7
Second ~cr: linens differential sau tion Ciccone ~okler ODE):
Tete cn aaustion hot confamns the “Second derivative op the
dependent vartatle he> 3
~The deners! forn q-the seaond-order oDe
1s expressedsolution of ordinary differerdt'al éoyrstors (ODES)
=the elution g, an addinay differential dustion usually means,
Finding Saclear—cut expre ssion fer y’ in terms of a defined
numter of simple -fimerims of
the Solution can be obtained based on relationship bbehicen oe!
ard |! Such 2 solution 5 Knosn as the clesed form,
— Numerical metheds also piovide Solution to ODES.
—the ‘numerical methads fir sdving an ong ate as follonas;
() Taylor’ series method.
(2) Ewer's method +
(2) Modified Euler methedt .
(4 Picarals method ej successive approximation,
(5) Runge — Kutta method.
(6) Predictor corrector methods : Adams Moulton Method.
= ta MATLAB environment, the. command _Asdlve. is used for
obtaining a general solution.
“Asolve’ Function :
Se
~ For obtaining 2 general solution dan ofe, the MATLAB
cowmare, alsolve, 1 Used
cw agslve command has the fovm {Ssmtad) ¢
clade (ear or [aeche(o/, vr!)
—Here, 27 is the €auation to be soled.
Bt hac to he typed 35 3 shaing-
yar is the Variable
Tt hes to be ped as sting.
AADLELVILI2 2Sim the dsdve(es') commana,
by MAnAB to be ECdefaulty
— 7 the. dsolve (‘ey "vary Command, User defines the Indepenctent
Veristle as var,
Hh MATLAB the letter D denotes differert’stion
1. dy,
Sh tav~ 108 is tyred th matiag as,
= Flid the general solution @ the fivetovder abe dy
Manas sexipt.
>> deolve('Dy= 4%t-4 271)
= Find the general Solution of the second oveler ODE,
dx
SE tae trae. using dese
Dasslve (pana Devx=0)
ans =
hlexpeo 2% exper)
Ge = ate2y using
—} Fo the Command winder, type
ner, Y= CE 2k a
ans = mn
chremate)= ate <1 Ts dispiageatie
WeC Bae aK’) MATLAB solves the Cavetin, dé
arene set =
amet "Ds
Gtetaya tes
MATA Sees the fauation, 4S = at.
Spasavet Ds=a"%"2!, 'a'D
I* re soucin 32 Lae daa] Cy
(aretnf2ten ey
s
ey
(Particular solution ef an ODE I
= Tf boundary ov initial conditions ave specified, # particular 4
Solution of an ODE can be obtahed. a
—A Fivst-ovdey bE reauives one_condition :,
A. second ~ovder ope teauiiies so conditions.
= The firsovder ote has the -form, *
dese C'en!, 'conds!, 'var')
= Forcthe Higher-ovcer OPE, the. Syntax 4S s
\asalveCeg/ 'conds', ‘ema!
=the boundary conditions ave. typed as _stzings
Tver
ete MATING fame
yee “ytay =A
Yoo 2a er
D
Yitay = a coeGomples.
= sole the first-order OPE} di sy oé5 | Lim the Tritial Condition
Y= using Matias.
8 In The MATLAB command window) type the following:
edsolve Covraty=60), tyeo)25')
ans= - | The onsner
I5— sofexpl ate Y= (5—(o/ett) is
clisplayed
Exomple >
Sie the Second-order ODE a durayoo|, Yeoet using Maro.
DasolveC'bay-2teyrory
q ns =
lexpley*caste)—expins sint
O}, 'ye)=4!, 'pyco)
© write 2 function that computes -f,f.---~ fn for the given tnput (Xt) .
Ber]
— "Use the built-in ope solvers ade2a or ade4s to solve the
feutztions!
@ The. function written In Step-2 {S Usedd as an Tofu fo ae2s or
ole as
the. suntan 15:
(time , solution’) = ode23('Your-function’, tspan, Xo)
time. saltial
conekivions:
solution rear
wasaie Funerion votre,
Aire:
Adak = \our-functin(te:
This funenian comans,
“the ans You Want 10
save.
tine sen
[to *nal]
‘Baract ‘the desired Variables frm the eutput One Ttermet the 1
results! |
(@ For asystem of n €quations the output matrix solution cantatas
“columns,opE23 and ODES ¢
soluing First-order equations Us
= solve the frst-crcer Linear differential Euston,
geewse
with the initial condition xo) =o
seeee: ,
INtite the. differential fustion(s) as set(aystern) A
First-order oves
Given Ope, dt x+t.
=
ntfs Written as,
[es=rey (Zaenge! gorction ale)
IS ERG
(hee an
Step-2:
"waite a function “to com pute The statecne)
derivative’, - aoe!
Function xdot = simpodeCe): |” Snnre
Xdot = xtt
peal syntex
te = simpede
xalo\ ees
xdot = XE
sw Werite and Save the file 2s, on Mofile
hit nome, |Advanced Data objects:
MATLAB SupppIts Severs) date objets.
— Mo of them ate + diystructumes ond
Aeells
Data objects ate special cases of the fundamertal data tye ,the
array
—Most familiay data object in MATLAB [5 sthe matrix,
Shuetuses|;
— A structure i, Like 2_vecord,
— Record-Keeping tn MATLAB fs Implemented Using structure
Deft Actucture Is a date construct with several name fields.
— one Yecond (structure) cantains Information abait serious
things. These. things will be Under diffeent_ heads Cfieldp
re can maintain 2 fecotd kok for our relatives.
—one page fthe book will be ‘alloted to tach a our relative.
— Ne can malist the -fllowing information tn éacn page 2S
headings
() Retationship
(ily Adsress,
ity Name of children
GV) pote of- birth of all children
LLLL
Example qa Structure. t
Doredte 2 Structure fallsem wlth three
3 oe,
Dut Hee, ne Nish to Yecord the hames of courses, Panes OF
corresponding professors and GD your perfirmance in ‘tests In
‘those. courses. ¢
Hn the commend winder 4 MATLas the following
pears is typed -
fietds: course, ProPand:
>
>
>
?
>
,
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
’
>
>
> Fallem. course = ‘estat's
>> Fallsem Prof
>? Fallen « Score
= ‘turing!s
[eas a:
> Faligem’
Fallsem =
course ! ‘estou!
prot: ‘Turing!
score: Ct0 75 95)
att ae
=e the above. Shuchre fallSem tne fields, case. and prof
comain Character StYINgS | score contains vector of numbers (Raw vedo)
Multiple recocis n a struchwe array:
— A etyudure can be madeas-an array (shucture av¥) .
— "the complete record fs stored as one slement of the array.
—Fn Structure array , fath lement must have Same. number Se
fields.
Sramele:
The shucwe. Fallsen becomes an array then tuo 4 more.
Wrecovds are added,
— Fa the Command Wine type the follosing
Sp Falison Go. cause ="Dhaad! ; alleen (3). course
>> Fall sem(z) - Por feqenbaunt, Fallsem a+ Prop
22 Fallsem(ad » Senre . = [12 15 Te]: FallSemda) score
2 'eomanujon':
= [Bs as 66]:
Tahen typed Aueried), MaTLAg rol gives structuel freformetion
about jhe shuchne «
Pallsem
1x2 struct anray Hh Fields:
prof
score— Fa the command winds ‘ys
[TE] >rFalisem(n> ceurse
ans =
Piao
(El >> Palicemcad. seavect)
ont
as
(3). >opolisem, score ,
ans =
2045 45
~ ans=
2 15 48
ans =
es as ce
[A >pfallsemay. Prof
ens
Tuving
TE) ppalisem(t+ seoret2)
ans=
as
vultiple records in field armas +
Te could Stove multiple vecoreis in a Single Shuchwe .
Thiste done, by Keeping the shudure 2S 1X4 +
xomple: :
in the example. FallSem, the Courses, Names cf professes el
Geotes Be Coded 25 2 4x matrk struct -
etter,
= Fa the cammmemel
winders, the fellowing is tured
Falisem. course
Fallaem. Prof,
allsem soe
= charCestot!, 'phyzoo!, 'math2us!);
= char(‘turing! 'pregenbaum! !Ramanujon');
= (Bo 4 95:72 45 Fes os 35 SE]:
09
RALLEREDEDELRR IeeeCreating structures :
ares
“We Can ciente A chuchie, by typing its Wome almg tity 2 Cad
and Assigning values to the field
~The other Way oh cresting 2 staichte, fe With the _Sfiuct function:
— shuct-function Syntax:
Struck (‘Feldnames), ‘Values! 'Geldnamae', value
~The shudure_Fallsem which ts Gesied Laclier, could al be
Created Using the struct -funchion.
—Tt's shatn helao;
Z tyes
@ As 2 single struct
Fallsem = struct (curse “char(testot!, ‘phyaco!, Imatn2it!)..
Prop’, charC'turing!, 'eregenbaum!, ‘Ramanugan),...
score, [80 15 95: 12. 15 1B: 45 35 26J);
As a stucture array;
Se
Fallgem =
Peet tourse!, tst01’, 'proe?, "Turing
"score, Ceo 15 453);
stuct('course, >Phy200’, ‘prof! ‘pregenbauin? .....
°score’, C12 15 Te);
Struct (course), wathast’ Spo? "Ramanujan? .
score”, Tas 25-6¢3));one :
‘enipulsting siefames structures :
- Manfpulation of shuchies fe simlorto spe. manipulation af
general arraus,
~Thete axe. Sexer2! functions to support: the rianipulation of
Structures,
~ they are;
() fieldnames
©@ sebfield
D se ield
BD vofteld,
@® isfretd
The names af above functions jill! Suggest, what the.
function sill do:
«
a
©
°
¢
©
©
e
oe
e
29999990