570 likes | 647 Views
Engr/Math/Physics 25. Chp5 MATLAB Plots & Models 3. Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu. Learning Goals. List the Elements of a COMPLETE Plots e.g.; axis labels, legend, units, etc. Construct Complete Cartesian (XY) plots using MATLAB
E N D
Engr/Math/Physics 25 Chp5 MATLABPlots & Models 3 Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu
Learning Goals • List the Elements of a COMPLETE Plots • e.g.; axis labels, legend, units, etc. • Construct Complete Cartesian (XY) plots using MATLAB • Modify or Specify MATLAB Plot Elements: Line Types, Data Markers,Tic Marks • Distinguish between INTERPolation and EXTRAPolation
Learning Goals cont • Construct using MATLAB SemiLog and LogLog Cartesian Plots • Use MATLAB’s InterActive Plotting Utility to Fine-Tune Plot Appearance • Use MATLAB to Produce 3-Dimensional Plots, including • Surface Plots • Contour Plots
Rectilinear Plots do Not Reveal Important Features when one or both of the variables range over several orders of magnitude Logarithmic Plots >> x = [0:0.1:100]; >> y = sqrt((100*(1-0.01*x.^2).^2 + 0.02*x.^2)./((1-x.^2).^2 + 0.1*x.^2)); >> plot(x,y), xlabel('x'), ylabel('y'); >> loglog(x,y), xlabel('x'), ylabel('y') • Rectilinear Plot • Log-Log Plot • LogLog Plot is MUCH More Revealing
Important Points to Remember You cannot plot negative numbers on a log scale Recall the logarithm of a negative number is not defined as a real number You cannot plot the number 0 (zero)on a log scale Recall log10(0) = ln(0) = − Therefore choose an appropriately small number (e.g., 10−18) as the lower limit on the plot. Tick-mark labels on a log scale are the actual values being plotted; they are not logs of the No.s The x values in the previous log-log plot range over 10−1= 0.1 to 102 = 100. Making Logarithmic Plots
Gridlines and tick marks within a decadeare unevenly spaced. If 8 gridlines or tick marks occur within the decade, they correspond to values equal to 2, 3, 4, . . . , 8, 9 times the value represented by the first gridline or tick mark of the decade. Equal distances on a log scale correspond to multiplication by the same constant as opposed to addition of the same constant on a rectilinear scale e.g.; all numbers that differ by a factor of 10 are separated by the same distance on a log scale. That is, the distance between 0.3 and 3 is the same as the distance between 300 and 3000. This separation is referred to as a decade or cycle Making Logarithmic Plots cont
MATLAB has three commands for generating plots with log scales: Use the loglog(x,y) command to have both scales logarithmic. Use the semilogx(x,y) command to have the x scale logarithmic and the y scale RECTILINEAR. Use the semilogy(x,y) command to have the y scale logarithmic and the x scale RECTILINEAR MATLAB Log & semiLog Plots
Again Plot SemiLog Plot Comparisons semilogx(x,y), xlabel('x'), ylabel('y') semilogy(x,y), xlabel('x'), ylabel('y') • x → log; y → linear • x → linear; y → log
Consider a Simple RC “Voltage Divider” Example Low Pass Filter • Finding the Magnitude of Gv 4.7 kΩ 22 nF • By the Methods of Junior-Level EE Find the Voltage “Gain”, Gv • In this Case the Time Constant, RC
Recall the Mag of G Example Low Pass Filter Plot • Lets “Center” out the M(ω) plot at ωτ= 1 • Thusω= 1/τ = 9671 rad/s 104 rad/s • Thus Make a log-log Plot for M(ω) (called a “Bode” Plot) with the Domain • 102≤ω≤106
Low Pass Filter Plot 4.7 kΩ 22 nF • This Ckt Leaves UNCHANGED, or PASSES, Low Frequency signals, but attenuates High Frequency Versions 70.7% left at ω = 1/τ 1% left at 106
Interactive Plotting in MATLAB • The “SemiAutomatic” interface can be very convenient when You • Need to create a large number of different types of plots, • Construct plots involving many data sets, • Want to add annotations such as rectangles and ellipses • Desire to change plot characteristics such as tick spacing, fonts, bolding, italics, and colors
MATLAB Interactive Plots cont • The interactive plotting environment in MATLAB Includes tools for • Creating different types of graphs, • Selecting variables to plot directly from the Workspace Browser • Creating and editing subplots, • Adding annotations such as lines, arrows, text, rectangles, and ellipses, and • Editing properties of graphics objects, such as their color, line weight, and font
Recall the Sagging Cantilever Beam Interactive Plotting • Plot Sag vs Time Using Interactive to • Go From This • To This Time For Live Demo
Format Plots by Coding • A Tedious Process for ONE-Time Use • HELP must be consulted a LOT to implement Complex Formatting • Useful forConstructinga Personal “Standard Format” for Plots
Code for Previous Plot % Bruce Mayer, PE % MTH-15 • 23Jun13 % XY_fcn_Graph_6x6_BlueGreen_BkGnd_Template_1306.m % % The FUNCTION x = linspace(-6,6,500); y = -x.^2/3 +5.5; % % The ZERO Lines zxh = [-6 6]; zyh = [0 0]; zxv = [0 0]; zyv = [-6 6]; % % the 6x6 Plot axes; set(gca,'FontSize',12); whitebg([0.8 1 1]); % Chg Plot BackGround to Blue-Green plot(x,y, zxv,zyv, 'k', zxh,zyh, 'k', 'LineWidth', 3),axis([-6 6 -6 6]),... grid, xlabel('\fontsize{14}x'), ylabel('\fontsize{14}y = f(x)'),... title(['\fontsize{16}MTH15 • Bruce Mayer, PE',]),... annotation('textbox',[.51 .05 .0 .1], 'FitBoxToText', 'on', 'EdgeColor', 'none', 'String', 'XYfcnGraph6x6BlueGreenBkGndTemplate1306.m','FontSize',7)
Example Consider a Humidification Vapor-Generator used to Fabricate Integrated Circuits 3D Surface Plots • A Carrier Gas, Nitrogen in this case, “bubbles” thru the Liquid Chemical, Becoming Humidified in the Process • The “Bubbler OutPut”, Qmix, is the sum of Carrier N2, QN2, and the Chem Vapor, Qv
Patent 5,078,922 Bubbler in Operation Water Surface Bubble Carrier N2 Flow Rate in slpm 6.35 mm Sparger Tube
The Details of Bubbler Operation Found in Bubbler-OutPut Physics • Chemical Vapor Output • Phs Absolute Pressure in Bubbler HeadSpace • Pv = Thermodynamic Vapor Pressure
Over a substantial Range of Temperatures Between Freezing & Boiling The ThermoDyamic Vapor Pressure of the Liquid Chemical Can be described by the Antoine Eqn1 Bubbler Physics • Where • T Absolute Temperature • A, B, C are CONSTANTS in Units consistent with T & Pv 1. R. C. Reid, J. M. Prausnitz, B. E. Poling, Properties of Gases & Liquids, 4th Ed., New York, McGraw-Hill, 1987, pg 208
In many cases C 0 In This Case The Antione Eqn Reduces to the Clapeyron Eqn2 Bubbler Physics cont • Then the Bubbler Eqn in terms of the Independent Vars QN2, Phs & T • or • Thus Pv(T) 2. R. C. Reid, J. M. Prausnitz, B. E. Poling, Properties of Gases & Liquids, 4th Ed., New York, McGraw-Hill, 1987, pg 206
Thus the Normalized Output, Qo, Can be Modulated by Pressure and Temperature Control We would Now Like to Plot Qo(Phs,T) for The Chemical TEOS Bubbler Physics cont • From the Manufacturer’s Data A summarized in [Mayer96], Find the Antoine/Clapeyron Constants for Pv in Torr • A = 19.3197 • B = 5562.30 Kelvins
General Synonyms: ethyl silicate, tetraethoxysilane, silicic acid tetraethyl ester, TEOS, tetraethyl silicate Molecular formula: (C2H5O)4Si Physical data Appearance: colorless liquid with an alcohol-like odor Physical data Melting point: −86 C Boiling point: 169 C Vapor density: 7.2 (air = 1) Vapor pressure: 2 mm-Hg at 20 C H2O → 17.54 mm-Hg Liquid Density (g/cm3): 0.94 Flash point: 39 C (closed cup) TEOS Chemical/Physical Data http://ptcl.chem.ox.ac.uk/MSDS/TE/tetraethyl_orthosilicate.html
Thus for TEOS the Clapeyron Eqn Bubbler OutPut - TEOS • We Now Want to Make a MATLAB Plot of Qo,TEOS for these Conditions • Now the TEOS Bubbler Normally Operates under these Conditions • T: 60-85 °C = 333-358 K • Phs: 250-750 Torr
The Command Session mesh Plot Example Time For Live Demo >> Trng = linspace(333,358,25); >> Prng = linspace(250,750,25); >> [T,Phs] = meshgrid(Trng,Prng); >> A = 19.3197; B = 5562.30; >> Pv = exp(A - B./T); >> Qo = Pv./(Phs - Pv); >> mesh((T-273),Phs,Qo), xlabel('T (°C)'), ylabel('Phs (Torr)'),... zlabel('Qo (slpm-TEOS/Slpm-N2)'), grid on,... title('Vapor Output From TEOS Bubbler') SQUARE XY Grid of 252 (225) points Bubbler_Qo_of_TPhs_1010.m
mesh Plot Result: Swap X↔Y mesh(Phs,(T-273),Qo), xlabel('Phs (Torr)'), ylabel('T (°C)'),... zlabel('Qo (slpm-TEOS/Slpm-N2)'), grid on,... title('Vapor Output From TEOS Bubbler')
Mesh Plot Caveats • To Make the Simple Surface Plot Shown the X-Y Grid Must be SQUARE • i.e.; [No. X-pts] = [No. Y-pts] • 25 in this case • Do NOT make the grid too DENSE • I tried the Qo Plot with a 500x500 Grid → 250 000 Points • Along with the 250 000 Qo calc Points, MATLAB had to operate on a Half a MILLION pts (took “forever”)
The Command Session contour Plot Example >> Trng = linspace(333,358,25); >> Prng = linspace(250,750,25); >> [T,Phs] = meshgrid(Trng,Prng); >> A = 19.3197; B = 5562.30; >> Pv = exp(A - B./T); >> Qo = Pv./(Phs - Pv); >> contour(Phs,(T-273),Qo), xlabel('Phs (Torr)'), ylabel('T (°C)'),... zlabel('Qo (slpm-TEOS/Slpm-N2)'), grid on,... title('Vapor Output From TEOS Bubbler') >> contour((T-273),Phs,Qo), xlabel('T (°C)'), ylabel('Phs (Torr)'),... zlabel('Qo (slpm-TEOS/Slpm-N2)'), grid on,... title('Vapor Output From TEOS Bubbler')
X → Phs X → T contour Plot Result
Other 3D Plot Commands cont meshz surf
Caveat on 3D Surface Plots • 3D Surfaces are Difficult for Many ENGINEERS/SCIENTISTS to Quickly Interpret • If you have a NonTechnicalAudience for your Plots, I suggest Sticking with 2D, Cartesian Plots
All Done for Today Excel Plot:BubblerOutPut
Engr/Math/Physics 25 Appendix Time For Live Demo Bruce Mayer, PE Licensed Electrical & Mechanical EngineerBMayer@ChabotCollege.edu
Starting Commands Interactive-1 >> delY_mm = [0, 2, 4, 4.5, 5.5, 6, 6.5, 8, 9, 11]; >> t_min = [0, 2, 4, 6, 9, 12, 15, 18, 21, 24]; >> plot(t_min, delY_mm)
Activate the FIGURE PALETTE Interactive-8 DoubleClick
Activate Axis-Title Format Box by Double-Clicking the Title Interactive 10
Interactive-11 • Change the Plot BackGround Color to Match the PowerPoint BackGround