Engr/Math/Physics 25 Chp5 MATLAB Plots & Models 2 Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engineering/Math/Physics 25: Computational Methods 1 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt 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 Engineering/Math/Physics 25: Computational Methods 2 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Learning Goals cont Construct using MATLAB SemiLog and LogLog Cartesian Plots Use MATLAB’s InterActive Plotting Utility to Fine-Tune Plot Appearance Create “Linear-Transform” Math Models for measured Physical Data • Linear Function → No Xform • Power Function → Log-Log Xform • Exponential Function → SemiLog Xform Engineering/Math/Physics 25: Computational Methods 3 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Learning Goals cont Use Regression Analysis as quantified by the “Least Squares” Method • Calculate – Sum-of-Squared Errors (SSE or J) The Squared Errors are Called “Residuals” – “Best Fit” Coefficients – Sum-of-Squares About the Mean (SSM or S) – Coefficient of Determination (r2) • Scale Data if Needed – Creates more meaningful spacing Engineering/Math/Physics 25: Computational Methods 4 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Learning Goals cont Build Math Models for Physical Data using “nth” Degree Polynomials Use MATLAB’s “Basic Fitting” Utility to find Math models for Plotted Data Use MATLAB to Produce 3-Dimensional Plots, including • Surface Plots • Contour Plots Engineering/Math/Physics 25: Computational Methods 5 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Why Plot? Engineering, Math, and Science are QUANTITATIVE Endeavors, we want NUMBERS as Well as Words Many times we Need to • Understand The (functional) relationship between two or More Variables • Compare the Values of MANY Data Values Engineering/Math/Physics 25: Computational Methods 6 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Sys3 2X200 MultiBlok, 997671 250-13.8 PreWeld Pi Tube-1 200 Individual Hole P (10X Torr) 175 Tic Mark Label 150 125 Connecting Line Axis UNITS Data Symbol 100 Tic Mark 75 50 25 PARAMETERS • For Single Tube Manifold • Flow = ??/0.24 slpm/hole • Exh to Atm Pressure (~750Torr) • Test Engr = DNStoddard, BMayer • Test Date = 09Mar00/10Mar DNS Tube-1 BMayer Tube1 DNS Normalized BMayer Normalized 0 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 Hole Number (1 = closest to Manifold Block) file = HbH997671PreW09Mar00.xls Engineering/Math/Physics 25: Computational Methods 7 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt SubPlots The subplot command creates several smaller “subplots” in the same figure. The syntax is subplot(m,n,p) This command divides the Figure window into an array of rectangular panes with m rows and n columns. The variable p tells MATLAB to place the output of the plot command following the subplot command into the pth pane. Engineering/Math/Physics 25: Computational Methods 8 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt SubPlot Example Consider an End-Loaded Cantilever Beam y F b x h L In ENGR36 & ENGR45 we will learn how the Applied Force-Load, F, affects the Beam Engineering/Math/Physics 25: Computational Methods 9 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt y F b SubPlot Example h L By the ENGR36 & ENGR45 Methods Analyze how the load affects the Beam in Terms of • SHEARING Force, V • BENDING-Moment, M • Vertical DEFLECTION, y Engineering/Math/Physics 25: Computational Methods 10 The V, M, and y functions vs the Normalized Distance Dimension x/L V x F 1 Vmax F M ( x) F x L x L x 1 M max FL L L 3 2 2 y x 1 x x 1 x x 3 3 ymax 2 L L 2 L L Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt x y F SubPlot Example b h L We Want to Plot V, M, and y ON TOP of each other vs the common independent Variable, x/L This is a perfect Task for subplot First Construct the functions Engineering/Math/Physics 25: Computational Methods 11 >> XoverL = [0:0.01:1]; V = ones(1, length(XoverL)) >> M = XoverL - 1; >> y = 0.5*((XoverL).^2) .*(XoverL -3); • Note the use of the ones Command to construct the Constant Shear (V) vector Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt x y F b SubPlot Example h L Next Make 3 subplots in an array with THREE Rows and ONE Column >> subplot(3,1,1) >> plot(XoverL,V), xlabel('x/L'), ylabel('V/Vmax'),... title('Cantilever Beam - Shear'), grid >> subplot(3,1,2) >> plot(XoverL,M), xlabel('x/L'), ylabel('M/Mmax'),... title('Cantilever Beam - Bending'), grid >> subplot(3,1,3) >> plot(XoverL,y), xlabel('x/L'), ylabel('y/ymax'),... title('Cantilever Beam - Deflection'), grid Engineering/Math/Physics 25: Computational Methods 12 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt x SubPlot Result Cantilever Beam - Shear V/Vmax 2 1 0 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 x/L Cantilever Beam - Bending 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.8 0.9 1 M/Mmax 0 -0.5 -1 0.5 0.6 0.7 x/L Cantilever Beam - Deflection y/ymax 0 -0.5 -1 Engineering/Math/Physics 25: Computational Methods 13 0.5 x/L 0.6 0.7 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Data-Markers & Line-Types The Data Marker and Line Type specifications in a Plot consist of optional Fields in the Basic plot statement To plot y versus x with a solid line, and then v versus u with a dashed line, type plot(x,y,u,v,’--’) • The symbols ’--’ represent a dashed line To plot y versus x with asterisks (*) connected with a dotted line, we must plot the data twice by typing plot(x,y,’*’,x,y,’:’). Engineering/Math/Physics 25: Computational Methods 14 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt DataMark & LineType Example To plot y versus x with green asterisks (*) connected with a red dashed line, again plot the data twice by typing plot(x,y,’g*’,x ,y,’r--’) Consider a PolyStryene Cantilever Beam (c.f. sld-8) Heavily Loaded for a “long” time Example: Mechanical Creep Engineering/Math/Physics 25: Computational Methods 15 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt DataMark & LineType Example We Would Like to plot the Vertical Deflection, Y, versus time, t, for a Constant Load using • Blue Colored Data Makers in the from of a + mark • Magenta Colored Dash-Dot (- .) Line to connect the Data Points Engineering/Math/Physics 25: Computational Methods 16 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt DataMark & LineType Example The Command Session for the Creep Plot • The Data Set as Row Vectors >> 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]; • The Plot Statement >> plot(t_min,delY_mm, ’b+’, t_min,delY_mm, 'm-.’),... xlabel('Load Application Time, t (min)'),... ylabel('Vertical Deflection, y (mm)'),... title('Polystrene Cantilever Beam Creep'), grid • Notice the Data is plotted Twice Engineering/Math/Physics 25: Computational Methods 17 • Notice also the BluePlus, and Magenta Dash-Dot Specs Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt DataMaker & LineType Result Polystrene Cantilever Beam Creep 12 Vertical Deflection, y (mm) 10 8 6 4 2 0 0 5 10 15 Load Application Time, t (min) Engineering/Math/Physics 25: Computational Methods 18 20 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt 25 More: Markers, Lines, Colors MATLAB Provides a Wide Range of Options for Plot-Lines & Plot-Markers Data markers† Dot (.) Asterisk (*) Cross () Circle ( ) Plus sign (+) Square ( ) Diamond ( ) Five-pointed star () Line types . * + s d p Solid line Dashed line Dash-dotted line Dotted line Colors –– –– –. …. Black Blue Cyan Green Magenta Red White Yellow k b c g m r w y †Other data markers are available. Search for “markers” or “LineSpec” in MATLAB help. Don’t forget the 'LineWidth', n Command to make thicker lines Engineering/Math/Physics 25: Computational Methods 19 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Labeling Curves The legend command automatically obtains from the plot the line type used for each data set and displays a sample of this line type in the legend box next to the selected text-string For Example again Consider RLC Circuit “Ringing” V t 9V e 0.3t cos13t Engineering/Math/Physics 25: Computational Methods 20 We Now wish to plot e−0.3t to Show the ENVELOPE of Exponential Decay d t 9V e 0.3t Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Labeling Curves Example Use Defaults for the main Function, V(t) Use Red, Dashed (--) Lines for the d(t) Decay The Calc and Plot statements >> t = [0:0.02:9]; >> V_t = (exp(-0.3*t)).*(9*cos(13*t)); >> d1 = 9*exp(-0.3*t); >> d2 = -9*exp(-0.3*t); >> plot(t,V_t, t, d1, 'r--', t, d2, 'r--'), xlabel('t'),... ylabel('V'), title('RLC Repsonse'),grid,... legend('Sinusoidal Oscillations', ’Exponential Decay') Engineering/Math/Physics 25: Computational Methods 21 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt legend Use Result RLC Repsonse 10 Sinusoidal Oscillations Exponential Decay 8 6 4 2 V 0 -2 -4 -6 -8 -10 0 1 2 3 4 5 t Engineering/Math/Physics 25: Computational Methods 22 6 7 8 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt 9 Labeling Curves with gtext The gtext Command allows the USER to Place the curve Labels at Any Location on the Plot with the Mouse. Let’s use gtext(‘string’) to Label the Decaying Sinusoid Plot with Labels Located in Close Proximity with the two Curves Engineering/Math/Physics 25: Computational Methods 23 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt gtext Use Result RLC Repsonse 10 8 6 Exponential Decay 4 Sinusoid V 2 0 -2 -4 Exponential Decay -6 -8 -10 0 1 2 3 4 5 6 7 8 t Engineering/Math/Physics 25: Computational Methods 24 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt 9 The hold command TYU T5.2-5 The hold Command “Freezes” plots for subsequent modification. Illustrate by T5.2-5 Example Say we Want to Plot over 0x1 Over this Range These functions are too difficult to Distinguish for gtext Labeling Solution → • Plot & Label y1 First • Plot & Label y2 2nd y1 sin x y2 x x 3 3 Engineering/Math/Physics 25: Computational Methods 25 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Making BETTER Plots The following actions, while not required, can nevertheless improve the appearance & clarity of your plots: 1. Start scales from Zero when possible – This prevents a false impression of the magnitudes of variations shown on the plot Invalid if we want to emphasize DIFFERENCES 2. Use sensible tick-mark spacing – If the quantities are months, choose a spacing of 12 because 1/10 of a year is not a convenient division. Engineering/Math/Physics 25: Computational Methods 26 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Making BETTER Plots cont – Tic marks should be Neither “Too” Course/Fine 3. Minimize the number of Zeros and Scientific-Notation in the data being plotted – For example, use a scale in µW (microWatts) to show Power Data Ranging Over 0.000011 – 0.000137 Watts (11 – 137 µW) 4. Determine the min & max data values for each axis before plotting the data. Then set the axis limits to cover the entire data range (or Span) plus an additional amount to allow for clearly understood tick-marking Engineering/Math/Physics 25: Computational Methods 27 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Making BETTER Plots cont – e.g; if the data on the x-axis ranges from 1.2 to 9.6, a good choice for axis limits is 0 to 10 This choice permits a tick spacing of 1 or 2. 5. Use a different line type for each curve when several are plotted on a single plot and they cross each other; – For example, use a solid line, a dashed line, and combinations of lines and symbols. Beware of using colors to distinguish plots if you are going to make black-and-white printouts and/or photocopies. Engineering/Math/Physics 25: Computational Methods 28 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Making BETTER Plots cont 6. Do not put too many curves on one plot, particularly if they will – Be close to each other – Cross one another at several points. 7. Use the same scale limits and tick spacing on each plot if you, or the plot Users, need to compare information on more than one plot. – This is VERY Important The Instructor Made this Mistake on the 1st Draft of His 1st Publication – Luckily a colleague spotted the error during her careful review of the draft Engineering/Math/Physics 25: Computational Methods 29 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Proper Comparison Scaling Same Scales Same Scales Same Scales Engineering/Math/Physics 25: Computational Methods 30 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Select Plot: WorkSpace Browser >> a = linspace(0,10,500); >> y = 4*cos(a)-22*sin(1.5*a+4); Engineering/Math/Physics 25: Computational Methods 31 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Select Plot: WorkSpace Browser Results can be a Plot of your choice >> B =[7, 19, 23, 3 ,17, 11] B = 7 Engineering/Math/Physics 25: Computational Methods 32 19 23 3 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt 17 11 Other Useful Plots Command bar(x,y) plotyy(x1,y1,x2,y2) Plot Description Bar chart of y versus x. Produces a plot with two y-axes, y1 on the left and y2 on the right Polar plot from the polar coordinates theta and r, using polar(theta,r,’type’) the line type, data marker, and colors specified in the string type. stairs(x,y) Stairs plot of y versus x stem(x,y) Engineering/Math/Physics 25: Computational Methods 33 Stem plot of y versus x. Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Column & Bar Chart MATLAB Col Chart MATLAB Bar Chart 25 >> Y = round(rand(5,3)*10); >> bar(Y,'stack') 5 20 4 15 y 3 10 2 5 1 3 sin(x) x-x /3 3 x 4 5 6 0 1 18 t0 = Dep-On Time Tcln Thc 16 System Description 14 12 10 8 6 3 4 5 6 7 Key Model Parameters (Cons/Opt) 47.96 • Adm = 4663/5362 Å-mm/s • Heat/Cool/Handling OH = 100/60 s/Dep-Cycle 63.76 • NF3 flow per aF-Gen = 1.2/1.2 slpm 42.36 62.48 file = ThruPut_Calc.xls 2 • Clean Efficiency = 2222/2222 scc-R/litre-NF3 • Clean Pre & Post Pumping & Venting = 4.8/3 min • 1 Astron per MultiBlok • Wfrs Between Cln = 5/15 (< 2.5/7.5 µm) • Lch assumes moveable (up/dwn) ceiling over the wafer load position 47.56 Conservative 72.68 Optimistic 63.54 93.72 6Ch-LT 2@3X 4 71.34 109.02 0 USG: mill sys3 USG: 2@3X/1 USG:2@3X/2 BPSG: mill sys3 BPSG: 2@3X/1 BPSG:2@3X/2 Engineering/Math/Physics 25: Computational Methods 34 2 APNext™ Advanced Architecture for 300mm/5kÅ-BPSG • Jun00 4Ch MillSys3 (200mm) 2 Wafer Processing Time Budget for 8k-USG and 5k-BPSG • Apr00 20 4Ch 1@3X 1 6Ch-T 1@3X 4Ch-L 2@3X 0 Processing Time (min/wafer) 0 0 20 40 60 80 100 120 Bruce Mayer, PE System ThruPut for 300mm Wafers (wph) file = ThruPut_Calc.xls BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt 8 9 10 Greek Letters on Plots (ΠΣλξ) Use the “\” then a “Character Sequence” in a Labeling Field Engineering/Math/Physics 25: Computational Methods 35 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Greek Letters on Plots (ωφΘΔ) Use the “\” then a “Character Sequence” in a Labeling Field Character Sequence Symbol Character Sequence Symbol Character Sequence Symbol \rho \forall \partial \sigma \exists \bullet • \varsigma \ni \div ÷ \tau \cong \neq \equiv \approx \aleph \Im \Re \wp \otimes \oplus \oslash \cap \cup \supseteq \supset \subseteq \subset \int \in \o \rfloor \lceil \nabla \lfloor \cdot · \ldots ... \perp \neg ¬ \prime ' \wedge \times x \0 \rceil \surd \mid | \vee \varpi \copyright © \langle \rangle Engineering/Math/Physics 25: Computational Methods 36 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt In the Greek…. ENGR25 • Engr Honor Soc -- 6 4 = ( ) 2 0 -2 - -4 -6 -6 -4 -2 Engineering/Math/Physics 25: Computational Methods 37 0 2 4 6 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Engineering/Math/Physics 25: Computational Methods 38 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Greek Code % Bruce Mayer, PE % ENGR-25 • 02Jul13 % 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{18}\Theta'), ylabel('\fontsize{18}\Psi = \phi(\Theta)'),... title(['\fontsize{16}ENGR25 • Engr Honor Soc \rightarrow \tau-\beta-\pi',]),... annotation('textbox',[.70 .25 .0 .1], 'FitBoxToText', 'on', 'EdgeColor', 'none', 'String', '\infty','FontSize',48) Plot Additions hold non/off Use the hold command to add lines, markers, and others with DIFFERENT formatting to an Existing Plot Some Help Searches that assist with formatting • Text Properties • LineSpec Engineering/Math/Physics 25: Computational Methods 39 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Example hold non/off ENGR25 • Bruce Mayer, PE • HOLD y () 10 9 8 7 6 XY f cnGraphBlueGreenBkGndSolidMarkerTemplate1306.m 5 4 3 2 1 0 -1 -2 -3 -4 -3 -2 -1 Engineering/Math/Physics 25: Computational Methods 40 0 1 2 3 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Engineering/Math/Physics 25: Computational Methods 41 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt hold non/off Code % Bruce Mayer, PE % ENGR-25 • 01Jul13 % XY_fcn_Graph_BlueGreenBkGnd_Solid_Marker_Template1306.m % % The Limits xmin = -3; xmax1 = 1; xmin2 = xmax1; xmax = 3; ymin = -4; ymax = 10; % The FUNCTION x1 = linspace(xmin,xmax1,500); y1 = 1-x1.^2; x2 = linspace(xmin2,xmax,500); y2 = 3*x2+1; % % The ZERO Lines zxh = [xmin xmax]; zyh = [0 0]; zxv = [0 0]; zyv = [ymin ymax]; % % the BASE Plot axes; set(gca,'FontSize',12); whitebg([0.8 1 1]); % Chg Plot BackGround to Blue-Green plot(x1,y1,'b', x2,y2,'b', x1(end),y1(end), 'ob', 'MarkerSize', 16, 'MarkerFaceColor', [0.8 1 1],... 'LineWidth', 5),axis([xmin xmax ymin ymax]),... grid, xlabel('\fontsize{16}\chi'), ylabel('\fontsize{16}y \equiv \phi(\chi)'),... title(['\fontsize{16}ENGR25 • Bruce Mayer, PE • HOLD',]),... annotation('textbox',[.15 .8 .0 .1], 'FitBoxToText', 'on', 'EdgeColor', 'none', 'String', 'XYfcnGraphBlueGreenBkGndSolidMarkerTemplate1306.m','FontSize',7) % % Turn-ON hold to ADD to BASE Plot Lines & Markers of different formats hold on plot(x2(1),y2(1), 'ob', 'MarkerSize', 11, 'MarkerFaceColor', 'g') plot(zxv,zyv, 'k', zxh,zyh, 'k', 'LineWidth', 3) plot([xmin xmax], [4 4], '-.m', [1 1], [ymin ymax], '-.m', 'LineWidth', 2) set(gca,'XTick',[xmin:1:xmax]); set(gca,'YTick',[ymin:1:ymax]) hold off Dual Y-Axis Plot 8% 40 y = -0.0048x2 + 0.9162x R2 = 0.9989 6% 30 p 4% 20 y = 9E-07x2 - 0.0004x + 0.0582 R2 = 0.9885 2% 10 Relative molar source vapor concentrations held constant: CS = 78.5% • CB = 12.1% • CP = 9.4% 0% 0 20 30 40 50 60 70 80 90 Source Chemical Flow Rate, Qv,tot (sccm) Engineering/Math/Physics 25: Computational Methods 42 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt -2 -1 b (nmol•cm •s ) 50 y = -5E-06x2 + 0.0009x + 0.0556 R2 = 0.983 BPSG Depostion Rate, BPSG Film Doping, b & p (mol% oxide) 10% poltyy in MATLAB Engineering/Math/Physics 25: Computational Methods 43 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt stairs Plot – sin(x) 1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 >> x=0:0.25:10; >> stairs(x,sin(x)); -0.8 -1 0 1 2 3 4 Engineering/Math/Physics 25: Computational Methods 44 5 6 7 8 9 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt 10 stem Plot - x y e sin x 2 0.35 >> x = 0:0.1:4; >> y = sin(x.^2).*exp(-x); >> stem(x,y) 0.3 0.25 0.2 0.15 0.1 0.05 0 -0.05 -0.1 -0.15 0 0.5 1 1.5 Engineering/Math/Physics 25: Computational Methods 45 2 2.5 3 3.5 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt 4 TYU T5.3-3 Polar Plot Archimedes Spiral r 2 The BMayer Plot : 0 4 Spiral of Archimedes 90 120 The interactive Session >> theta = linspace(0, 4*pi, 500); >> a = 2; >> r = a*theta; >> subplot(1,1,1) >> polar(theta, r), title('Spiral of Archimedes') 60 20 150 30 10 180 0 210 330 240 Engineering/Math/Physics 25: Computational Methods 46 30 300 270 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt All Done for Today SeaShell Built on Archimedes Spiral Engineering/Math/Physics 25: Computational Methods 47 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt Engr/Math/Physics 25 Appendix f x 2 x 7 x + 9 x 6 3 2 Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engineering/Math/Physics 25: Computational Methods 48 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt gtext Demo The Command Session >> t = [0:0.02:9]; >> V_t = (exp(-0.3*t)).*(9*cos(13*t)); >> d1 = 9*exp(-0.3*t); >> d2 = -9*exp(-0.3*t); >> plot(t,V_t, t, d1, 'r--', t, d2, 'r--'), xlabel('t'),... ylabel('V'), title('RLC Repsonse'),grid,... gtext('Sinusoid'), gtext('Exponential Decay'),... gtext('Exponential Decay') • TWO “Exponential Decay” Labels; one each for the TOP and BOTTOM Curves – Demo_Chp5_gtext_6010.m Engineering/Math/Physics 25: Computational Methods 49 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt hold Demo 0.9 >> x = [0:0.01:1]; >> y1 = sin(x); y2 = x-x.^3/3; >> plot(x,y1), gtext('sin(x)'), hold, plot(x,y2), xlabel('x'),... ylabel('y'), gtext('x-x^3/3') Current plot held 0.8 0.7 0.6 x-x 3/3 y 0.5 sin(x) 0.4 Formatting Info 0.3 0.2 0.1 0 0 0.1 0.2 0.3 0.4 Engineering/Math/Physics 25: Computational Methods 50 0.5 x 0.6 0.7 0.8 0.9 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Plot_Model-2.ppt 1