# Applied Numerical Methods with MATLAB

(Parte 7 de 16)

Food Drink

Skin

Metabolism FIGURE PI.IOFIGURE PI.I2

PROBLEMS r9 where g(r) : gravitational acceleration at altitude .r (in m) measured upward fronr thc earth's surface tm/s2). gtO) : gravitational acceleration at the earth's surface (! 9.8 rn/sr), and R : the carth's radius (= 6.37 x 106 mt. (a) In a fashion similar to the derivation of Eq. (1.8), use a force balance to derive a ditlerential equation for velocity as a function of time that utilizes this more complete representation of gravitation. However. lbr this derivation, assume that upward velocity is positive. (b.1 For the case where drag is negligible, use the chain rule to express the differential equation as a function of altitude rather than time. Recall that the chain rule is du du d-r dt d.r dt

(c) Use calculus to obtain the closed form solution where u = u,, at.r : 0. (d) Use Euler's rnethod to obtain a numerical solution from r : 0 to 100,0 m using a step of 10,0 m where the initial velocity is 1400 m/s upward. Compare yor,r result u ith the analytical solr"rtion.

l. l{ Suppose that a spherical droplet of liquid evaporates at a rate that is proportional to its surface area.

dV:: -kA dt rvhere V: volume 1mm3), t : time (hr), k : the evapol'ation rate (m/hr), and A : surface area 1mr). Use Euler's method to conrpute the volume of the droplet from I : 0 to l0 min using a step size of 0.2,5 min. Assume that ft : 0.1 m/min and that the droplet initially has a radius of 3 m. Assess the validity oi your results by determining the radius of your final computed volume and verifying that it rs consistent with the evaporation rate.

l.l-5 Newton's law oicooling says that the temperature of a body changes at a rate proportional to the difference between its temperature and that of the surrounding medium (the ambient temperature).

dT-;at : -k(T - T") where Z: the temperature of the body ("C), r : time (rnin), k : the proportionality constant (per minute), and 7, : ths arnbient temperature ("C). Suppose that a cup of coft-e originally has a temperature of 68 'C. Use Euler's method to compute the temperature from I : 0 to l0 min using a step size of I min if I.. : 2l "C and ft : 0.01 7/min.

|.16 Afluid is pumped into the network shown in Fig. P1.16.

lf 0, : 0.6. O., : 0.4. Qt:O.2. and Qo : 0..1 mr/s. determine the other flows.

i ilr*?-i=-i--I

 i-. er-:- -s ;-*-*L*-i

iri:;\$b o,l "i "i "'it'ili FIGURE PI.I6

\ iiEi;4+'" ,l

MATLAB Fundomentols

m8 ut

The primary objective o1'this chapter is to provide an introductiorr and overview of how MATLAB's calculator mode is used to implcment interactive cornputations. Specific objectives and topics covered are

' Lcarning how real ancl cornplex nurrrbcrs are assigned to variables . Learning how vectors and matrices are assigned values using sinrple ussignrnent. the colon ope'rator', and thc .l irs;p.r,:c and 1oq1,;piic:,--- l'ttnctitlns.

. Llnderstanding thc priority rulcs firr constructing mathernatical cxpre-ssions. . Gaining a gencral undcrstanding ol'built-in lr-rnctions and how you can lcarn tnore about them with MA'I'LAB's Help f acilities. . Learning how to usc vectors to crcirtc a sinrplc linc plot basecl on an equation.

I n Chap. l. we usctl ir firrce balance to detcrnrine the tcrminal velocity of a fiec-falling

I ohjecl likc ir hLrrrgce jurnpcr. T wher-e r.,, : ternrinal velocity (nr/s), ,q : gravilational accelerertion (m/s'). m : mass (kg), and t',, : a drag coefl'icient (kg/m). Aside from prcdicting the terminal velocity, this equa- tion can also be rearranged to compute the drag coefficicnt tsi V t,t

(2. I ; 20 ffi=?N 4_

,f = %. uE-1 5t zr'+ zl x+ %I

2r 2 r THE MAT4gllyllerynENl

Dotoforthemossondossociotedtermino|velociliesofonumberofiumpersTABTE 2.I

m,kg

5l l

Thus, if we nleasure the terminal velocity of a number ol .iumpers of knclwn equation provides o *t-' t.l e stimate the drag coeificient' The clata in Table 2' I lectu'd lorlhis purpose' m, n ,.,,.nrl rn rn:rlv.zr'srrch dltu. Beyond In this chapter, we will leartr how MATLAB can be uscd to analyze t showinghowMATLABcanbeenlployedtocolnputeqtrantitieslikeclragcoetTicients'we willalsoillustratchowttsgraphicalcapabilitiesp,*i.t.adtlititlnalinsightintosuchanalyses.

MATLABisacomputerprogralxthatprovi<lcs.theuserwithaconvelrietrtenvirontlrentfclr perfornirrg many typcs.ol.ctilculaticrns. ln particular, it prtlvides a very nice tool to inrple.

mass, this were col-

2.r

" " !i:H:i:illl1l;|; "v t o ope rute * *' 1 P, :', :,' ::::::: :::):i:I;:;: i' ffi :l f.:l,'Ji:'.:il{; ilJfil'.":ili: ;::'# "' *.,ln "'" u'T- ":1 crc ati n g p r ot s r n Chap. 3, we show how sr'rch commands can be usecl to create MAft-AB progralns' onefurther.notc'.[hischapterhasbeenwrittenasalrancls-tlrrcxcl.cise.Thatis,yott shoultl rcad it while ,,tring in fiont o1'youl cornpLrtcr. The m.st elficient way to beconle oroficientist'oacttrallyinl;llctlentthcctltntrratrclsonMATLABasyouprocccdthrotrghthe following material' fUeif-A,B uses three primary witrclows:

. Conrtnancl winclow' Uscd to enter commancls and data'

. C."pt,i.* windtlw' Used kr display plots and graphs' . gaii winclow' Usecl t'r creute and edit M-filcs'

In this chapter, we wilr r.rake usc of thc c.mmand ancl graphics wind.ws' ln chap' 3 we

*i ut. the edit window to crcatc M-iiles' Afier starting Md;;;' tht tu'ntunti window will open with thc commancl prompt bcing disPlaYcd

I a scqucntiitl lltshitrn as yoLl typc in cont- The calculator nlode o1'MATLAB oper''rtcs lr mancls line by line' For each cotnurancl' you get'r-result Lh::s' you can think of it as oper- i"g f if,. a uery l'ancy calcttlator' For exanlplc' if you typc tn -_-, 51 Lo

MATL.AB will disPlaY thc rcsult' a,t-,=,,

'MA|l,ABskrpsalincbctwccllt|-r|ahel(l,rrl.)ltndthcnunlbcr.(-]).Herr-.\$1.(,mitsllchbllnkljncstor co.ciscness. varu aun aun,,art .uh.ither rtant line's are includctl with thc I ()r:r'1i ( .ilLlrfri:1 Aud !.r:'r'' 1c'i':'r comlrtnds.

8ffi AL r- ?t 5tqAzt\4x 4,.-I LJ '

2 MATLAB FUNDAMENTALS

Notice that MATLAB has automatically assigned the answer to a variable, ans. Thus, you could now use ans in a subseouent calculation:

'- ars + I with the result

MATLAB assigns the result to ans whenever you do not explicitly assign the calculation to a variable of your own choosing.

2.2 ASSIGNMENT

Assignment refers to assigning values to variable names. This results in the storage of the values in the memory location corresponding to the variable name.

2.2.1 Scolors

The assignment of values to scalar variables is sirnilar to other conlputer languages. Try typing

Note how the assignment echo prints to confirm what you have done:

Echo printing is a charactelistic of MATLAB. lt carr be suppressed by terminating the command line with the semicolon (; ) character. Try typing

(Parte 7 de 16)