matlab - W. type Result Example snm'i' Scaled Fixed-pour...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: W. type Result Example snm'i' Scaled Fixed-pour formal will 5 digilr, '5 _ 14'] in long Scaled fixedpoin: lormoi wiih 15 digits for double and 7 digits lor Single ll. [4 new}. {HH‘FTH Sliflzt e Homing-pew lormoi waih 5 digiia 3. L4169+DUU long e Flooling-pom‘ iormoi wnh 15 digits lor double and 7 Oigns lor single 3 . 1:1 L592653589793e+000 5110.”: -; Besl {Jl lixeLl- Oi Flooring-pun” lorrnci wi1li 5 digits 3. 1416 Jong g Bes' ol lixed- iJI Hauling-pail“ loimur wiili 15 digiib lUi duuble 3 .14159265 358??? Eh: :' L eng long eizg hank UPd 7Efigfl5lur$ngb Engineering fame! with at lecsl 5 digils Grid :1 power ilier is o rnulliple ol 3 Engineering lonnui wi'h BXQCll'f Inf) mgni'riconi digils UrIG o powe' l'iUl is u muliipe ol 3 Fixed dollms and cenis -~=r 1):: ljl;il;EJ:L-:Il_':ll 5| = [ 3; .1: w .1416:+DUU 'i ‘ 14159265358919e+000 .14 ill”. by lrunepmlng :i rnw veeinr with the ' eperflmr. in = r 9. r1 5 e 1.2:; 11 The reeult in all three eiieee will he lei-— fi-ib.u Ffl up 'our variables are; I, .35 a a I] e b x or. with more detailt enter the whos command: whos Home Sire Byte: Class A 3x3 72 double array 6i 1x5 40 double array ens Lx‘l d double array h nxi en double array x lxl 1e double array iCOmpLCK] Grand tonal is El elemnnLE using 176 bytes For example. the fourth element of the Colunm rector L: can be displayed as. 1-: rs: := $1.311.- F5 For an array. P~ tn, :1} selects the element in :nth row and the nth column. For example. 5- £[:.?) There are several built-in functions; that can be USCG to create matrices. For example. the ones; and zeros functions create vectors or matrices. filled Irt-ith ones and zeros, respectively. Both have two lll'gUt'llCllfH. the first for the number of rover-L and the second for thenumberofuflumneIfiwexmnpm,unxmuen2 XHInmflxofzan L-I : 7.611135 {2 , .3} E. : U 0 U [.l U U Similarly, the ones function can be uer to L‘l'Etl'EE Ll row vector ol'ones: ;a:,- U — out-:33 { l. .l I 1.1 increment of one: 2:} t = 1:5 t : 1 E 3 d l:- -|- If colons are used to separate three numbers. MATLAB generates the numbers between the first and third numbers using, an increment equal to the second number: :«rn- t = i:0.5:3 t :- 1.3000 1.5000 2.0000 2.5000 3.0000 Note that negative increments can also be used 3': L = 101-}.sz i0 9 8 7 E 5 Aside from creating series of numbers, the colon can also he used as a wildcard to se- lect the individual rows and columns of a matrix. When a colon is used in place of a spe- cific subscript. the colon represents the entire row or column. For example. the second row of the matrix A can be selected as in his Al2,:l ens e 4 5 6 We can also use the colon notation to selectively extract a series of elements from within an array. For example. based on the previous definition ofthe vector t'. .>;-- [12:41 ans : 9 8 7" Thus. the second through the fourth elements are returned. The l inspacre and logspace functions provide other handy tools to generate vectors of spaced points; The 1 int-spdce function generates a row vector of equally spaced points. It has the form 1 inspace ixl , x2, :1} which generates n points hetvveen x1 and x2. For example linspecet0,1.61 ants : 0 0.2000 0.4000 0.6000 0,8000 j.0000 which generates n logarithmically equally spaced points between decades 10"-I and 10'". For example, >> legspacet-l,2,4) ans = 0.1000 1.0030 10 0000 100.0000 If n is omitted, it automatically generates 50 points. Expflne chenien ldegehen * .r’ Mulliolieahcn [and elimsie-n 1 Ehdm3mf - — Addiricn and Eufllrfl-fllifln .J-J- !. :1- dI'lE T l E E? 04 125 ElE 3113 572 T29 a He'll} [fig LOG Natural logarithm. LOGIXJ is the natural logarithm of Lhe elements of K. Complex JLESLlLS are produced i£ X is 1101.. posizive. See also LOG}, LOGIC, EXP, LOGH. }? loglfll 6.113 = 3 0.6931 1.0930 . 330i l.hflgfl l.TQlH 1.9459 2.0794 2.1972 >3 sqrtmtAJ ans = 0.4493 + C.T623i 0.5526 + 0.20681 0.6555 - 0.348Ti 1.0'85 + 0.08d21 1.2515 + 0.022Hi 1.d3£4 — 0.0385i 1.53T3 — 0.5940i 1.9503 — 0.16111 2.3134 + 0.271Ti The round function rounds the elements of E to the nearest integers: fih reundtfl] ans = .—. m4 ~2 -L 1 2 2 The cell {short for ceiling] function rounds to the nearest integers toward infinity: s} ceiltet {—1113 = 1 1 -1 2 2 2 The :‘ leer function rounds down to the nearest integers towttrtl minus infinity: ‘2 2: £100 5 t 1:: 1 arts; —. —2 —2 —2 l l l 1 h} miniF}.max[F}.meantFJ.preth}.5ertEF} Create n enluntn sector It that enntains values from 0 ten 20 in steps of 2: n C- M M D r; t ' ' ' te a .IIATLAB allows graphs to be created qmckly and conveniently. For esample, to crea rraph of the t and v arrays from the data above, Euler m or. I' t. ‘Jl 9h Lithi'PluL oi u uwr5u5 L'l w- slubrll I: "trained of 1_"] '~ 3: | a1 big I I; ' 'u'rfL 1 LC? {‘3 l' U ' l g r“ i d TABLE 2.2 Specifiers fer colors, symbols, and line types. Colors Line Types B'u-e b Poi u 'l . Solid Green g C i'cie . Dolled Red I X-mork '_ L}: shdol C yon 1" H u 5 Dr: shed :‘s‘ogaao m SIC" Yellow 3; Square Blucl, k DIOITIOI'ICl Triorigloldcv-m} Ti rCH :gfei up} irianglefleil] Incogelrigh'} Der logrom Hemgrom The p 101. cerium-and displays a solid line by default. lfyou want to plot each point Wilh a symbol. you can include a specifier enclosed in single quotes in the plot. function. Table “3.2 lists the available specifiels, For example. if you want to use open circles enter :-'.-.- plot (r, U, '0') MATLAB allows you to display more than one data set on the same plot) For example. if you want to connect each data marker with a straight line you could type. -g-lor_. :iL, t; 1;. 'u-‘J In contrast, the following Commands would result in both lines and symbols being displayed: '22-: FIDL It, ‘5'," 1- Raid on plot it, 'v, '0') #9 hold Off We can demonstrate SL1 bpl at by examining MATLAB‘S capability to generate three— dimensionnl plots. The simplest manifestation of this capability is the plot3 command which has the syntax plotJ [x_. y, 3} where X. y, and z are three vectors ofthe same length. The result is a line in three-dimensional space through the points whose coordinates are the elements of x, y: and z. I T Leh- Eprin:f:"1‘he vc-leci y is %H.4f min-.125 'v'fllfifl'll.1f:' _. .' The '-.-'E-lc:c:i_':‘,r' is 52D.t31 5 min 1 : iflDuLi'EdHfi {kg}: '1 TABLE 3.1 Commenly used thermal and control codes mpleyed with lhe ferintf iuncliein. Fnrmefl Eel-din Description 95d wheat-2' itirmn’ id: Seer-h? I: inrmut w 1h iCWE’FCIUFxE' e 53;: Sc Enh‘n: inr'm‘ With upper-35c- E '%i' :Jec'ficl inrrn-al I”; ire rue-e Lempnm oi Tee 0* e l: Central Code Din-scriplinn "-IE E'flrt new line ‘i '_' Tfilfl ...
View Full Document

Page1 / 7

matlab - W. type Result Example snm'i' Scaled Fixed-pour...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online