【正文】
W i d t h 39。 , 3 . 0 , 39。 M a r k e r S i z e 39。 , 6 , …39。 M a r k e r E d g e C o l o r 39。 , 39。 r 39。 , 39。 M a r k e r F a c e C o l o r 39。 , 39。 g 39。 )Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 74 Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 75 Enhanced Control of Text String The font used to display the text can be modified by stream modifier. Stream modifier : a special sequence of characters that tells the MATLAB interpreter to change its behavior. Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 76 \bf Boldface \it Italics \rm Restore normal font \fontname{fontname} Specify the font name to use \fontsize{fontsize} Specify font size _{xxx} The characters inside the braces are subscripts. ^{xxx} The characters inside the braces are superscripts Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 77 Special Greek and mathematical symbols are created by embedding special escape sequences into the text string. Escape sequences : are subset of the special sequences support by the TEX language. Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 78 Character Sequence Symbol Character Sequence Symbol Character Sequence Symbol \alpha α \int ∫ \beta β \cong ≌ \gamma γ \Gamma Γ \sim ~ \delta δ \Delta Δ \infty ∞ \epsilon ε \pm 177。 \eta η \leq ≤ \theta θ \geq ≥ \lamda λ \Lamda Λ \neg ≠ \mu μ \propto ∝ Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 79 \nu ν \div 247。 \pi π \Pi Π \circ 176。 \phi θ \leftrightarrow ? \rho ρ \leftarrow ← \sigma ζ \Sigma Σ \rightarrow → \tau η \uparrow ↑ \omega ω \Omega Ω \downarrow ↓ Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 80 If one of the special escape characters \, {, }, _ or ^ must be printed, precede it by backslash character. String Result \tau_{ind} versus \omega_{\itm} ηind versus ωm \theta varies from 0\circ to 90\circ θ varies from 0o to 90o \bf{B}_{\itS} BS Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 81 Polar Plots polar (theta, r) theta : an array of angles in radians。 r : an array of distances. Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 82 Example — Cardioid Microphone The gain of such a microphone varies as a function of angle according to the equation. g : a constant associated with microphone. θ: the angle from the axis of the microphone to the sound source. 2 (1 c o s )G a in g ???Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 83 Example —Electrical Engineering : Frequency Response of a LowPass Filter RVi CVoChapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 84 R = 16kΩ C = 1μF 112oiVV j fR C?? ?Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 85 Example — Thermodynamics: The Ideal Gas Law P : the pressure of the gas in kilopascals (kPa)。 V : the volume of the gas in liters (L)。 n : the number of molecules of the gas in units of moles (mol). R : the universal gas constant ( LkPa/mol K)。 T : the absolute temperature in kelvins (K). PV nRT?Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 86 (a) T = 273K, the volume of the gas vary as its pressure varies from 1 to 1000 kPa? Plot using a solid red line, with a width of 2 pixels. (b) T = 373K, Plot again on the same figure using a dashed blue line, with a width of 2 pixels. Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 87 Annotating and Saving Plots GUIbased tools Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 88 Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 89 Use ―File/Save As‖ menu, *.fig file. Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 90 More on Debugging MATLAB Programs symbolic debugger Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 91 Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 92 Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 93 Use Breakpoints menu. All breakpoints may be lost when the program is saved. Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 94 Summary ?Basic types of MATLAB branches。 ?Relational and logic operations。 ?Additional information about plots。 ?Symbolic debugger. Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 95 Summary of Good Programming Practice 1. Be cautious about testing for equality numeric values — roundoff error. 2. Follow the steps of the program design process. 3. Always indent code blocks in if and switch constructs. Chapter 3 Branching Statements and Program Design 10/23/2022 Hangzhou Dianzi University 96 MATLAB Summary axis subplot figure switch hold try/catch if ischar (a) isempty (a) isinf (a) isnan (a) isnumeric (a) pola