„  1999 BG Mobasseri1 9/18/2015 June 2 GRAPHICS IN MATLAB- PART I BASIC PLOTTING.

Slides:



Advertisements
Similar presentations
Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Advertisements

Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Lecture (4) Plotting & Programming (1) Eng. Osama Talaat 1.
2D Plots 1 ENGR 1181 MATLAB 12.
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
Matrix Manipulation and 2D Plotting
Introduction to Engineering MATLAB – 10 Plotting - 3 Agenda Special 2-D Plots fplot command.
1. Overview 2. plot in 2D 3. Plot in 3D 4. Other possible charts 5. Engineers: label your plots! 6. Plots & Polynomial Plotting 11.
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 4.
MATLAB GRAPHICS 2-D.
MATLAB - Lecture 22A Two Dimensional Plots / Chapter 5 Topics Covered:
EGR106 Week 6 MATLAB FILES Two Dimensional Plots Multiple Plots
EGR106 Week 4 Two Dimensional Plots Multiple Plots Plot Formatting Homework.
Introduction to Matlab 332:202 Discrete Mathematics Spring 2007.
Lecture 9 Plotting in 2-D Plotting in 2-D, Plotting Multiple Curves, Plotting with Figures, Plot Settings, Scaling, Legends © 2007 Daniel Valentine. All.
Plotting - Advanced. FPLOT Plots a function f(x) written as a string within quotation marks. The free variable needs to be designated with x. The lower.
An introduction to Plotting in MATLAB Rikard Johansson Department of Biomedical Engineering (IMT) Linköping University
 1999 BG Mobasseri1 8/29/2015 MATLAB GRAPHICS - PART II ADVANCED PLOTTING June 4, ‘99.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
PLOTS AND FIGURES DAVID COOPER SUMMER Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
1 "A picture is worth a thousand words." Graphical representation is useful for: Error detection - you can locate outliers in a dataset, program bugs,
MATLAB Plotting With MATLAB 1. Two Dimensional Plots The xy plot is the most commonly used plot by engineers The independent variable is usually called.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
EECE 360/460 Matlab Tutorial Jan Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs.
COMP 116: Introduction to Scientific Programming Lecture 5: Plotting, Scripts and publishing.
MAE 1202: AEROSPACE PRACTICUM An Introduction to MATLAB: Part 2 Mechanical and Aerospace Engineering Department Florida Institute of Technology Developed.
Recap Sum and Product Functions Matrix Size Function Variance and Standard Deviation Random Numbers Complex Numbers.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Barbara/Pratik/Yu. Outline Matlab desktop M-files Variables Arrays Plots.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB – 2D Plots 1 Go to the class drive: ---> MatLab - Graphing ---> Seed Files.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
EXCEL CHARTS. CHARTS Charts provide a way of presenting and comparing data in graphical format. Embedded charts or chart sheets Embedded charts are objects.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
2D Plots 2 ENGR 1181 MATLAB 13. Plotting in the Real World 2D plots generated by MATLAB can be used in a variety of fields, including the one shown here,
1. Overview 2. plot in 2D 3. Plot in 3D 4. Other possible charts 5. Engineers: label your plots! 6. Plots & Polynomial Plotting 11.
Sept. 26, 2005 Lecture 6 - By Paul Lin 1 CPET 190 Lecture 6 Problem Solving with MATLAB
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
ECE 351 M ATLAB I NTRODUCTION ( BY T EACHING A SSISTANTS )
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 2 in MATLAB Topics Covered: 1.More about 2-D plots  Placing multiple.
GRAPHICS AND VISUALISATION WITH MATLAB UNIVERSITY OF SHEFFIELD CiCS DEPARTMENT Deniz Savas & Mike Griffiths May 2015.
Introduction to Engineering MATLAB – 9 Plotting - 2 Agenda Formatting plots.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Lab 2 : potting to Matlab Networks.
CS100A, Fall 1998, Lecture 191 CS100A, Fall 1998 Lecture 19, Thursday Nov 05 Matlab Concepts: Matlab arrays Matlab subscripting Matlab plotting.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
Let’s stay fresh with C. What does this print? void mystery(int * x); main(){ int a = 5; mystery(&a); printf("%d\n",a); } void mystery(int * x){ int y;
Introduction to plotting data Fish 552: Lecture 4.
EGR 106 – Week 5 – 2-D Plots Question : Why do engineers use plots? Answer : To analyze, visualize, and present data. Matlab has many useful plotting options.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Plotting ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Creating a Plot The plot function can take one or more inputs; e.g. plot (x, y) or plot (y) Note that in the two-argument version, the vectors x and.
Course Information Do not rely on color to distinguish curves (due to black-white printout). Use different line styles to distinguish curves (solid, dashed,
Lecture 25: Exploring data
Matrices and Arrays.
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
Net 222: Communications and networks fundamentals (Practical Part)
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files) Double click this icon
MatLab – 2D Plots 2 MATLAB has many built-in functions and commands to create various types of plots. Instructor notes: We start with an example of some.
MATLAB How to use (using M-files)
Plotting Signals in MATLAB
Introduction to Matlab
Simulate Multiple Dice
Presentation transcript:

„  1999 BG Mobasseri1 9/18/2015 June 2 GRAPHICS IN MATLAB- PART I BASIC PLOTTING

„  1999 BG Mobasseri2 9/18/2015 PLOTTING A SINGLE ARRAY The most basic command that puts a graphic on screen is plot If y is an array, plot(y) simply plots values of y vs. their array index position Do this: –t=[0:0.01:1]; –y=cos(2*pi*t); –plot(y) Notice numbers on x-axis. They are not time

„  1999 BG Mobasseri3 9/18/2015 PLOTTING ONE ARRAY AGAINST ANOTHER If t is one array and y another, plot(t,y) plots y vs. t. Do this: –t=[0:0.01:1]; –y=cos(t); –plot(t,y)

„  1999 BG Mobasseri4 9/18/2015 Try it! Plotting one array against another generates creative figures For example, define your x-array as cos(2(pi)t) and y-array as sin(2(pi)t). Then plot y vs.x. Let t run from 0 to 1 as before Do the same for 2cos(2(pi)t) vs. 4sin(2(pi)t)

„  1999 BG Mobasseri5 9/18/2015 Plots via a matrix The argument of plot can be a matrix. In this case, each column is plotted separately on the same axis. This is a compact way of plotting several graphs on the same axis Try –t=0:pi/16/:2*pi; –x=[cos(t)’,sin(t)’] –plot(x) each column is plotted separately vs. position

„  1999 BG Mobasseri6 9/18/2015 Plotting a matrix against another array Let Y be a matrix and x be the vector of variables, then –plot(x,Y) plots columns of Y vs. x on the same graph Try this –t=0:pi/16:2*pi; –Y=[cos(t)’,sin(t)’] –plot(t’,Y) each column plotted separately vs. another array

„  1999 BG Mobasseri7 9/18/2015 Putting multiple plots on the same graph There are 3 ways to do this. Want to plot 3 data vectors y1,y2 and y3 vs. t Method 1: –Y=[y1,y2,y3] –plot(t,Y) Method 2 –plot(t,y1,t,y2,t,y3) Method 3 –Use hold command

„  1999 BG Mobasseri8 9/18/2015 RC circuit response Capacitors charge and discharge following an exponential curve. Plot the following 3 voltages on the same graph for 0<t<5.

„  1999 BG Mobasseri9 9/18/2015 Try it!

„  1999 BG Mobasseri10 9/18/2015 hold COMMAND Once hold is turned on, all subsequent plot commands are superimposed on the same axis hold cycles between on and off. For example, –plot(t,y1) –hold on –plot(t,y2) –plot(t,y3) –hold off

„  1999 BG Mobasseri11 9/18/2015 Homework #1 Plot y vs. x over the range x=[-2,2]. In addition to your m-file, save your figure and send it to me

„  1999 BG Mobasseri12 9/18/2015 Plotting parametric functions- fplot. You may want to plot a function, rather than an array of numebrs, against a variable. Example is plotting cos(x). The command is fplot(‘cos’,[-pi pi]) Note that the function must be known to MATLAB such as sine and cosine function x range

„  1999 BG Mobasseri13 9/18/2015 MULTIPLE PLOTS USING fplot fplot(‘[sinc(x),sinc(2*x)]’,[-2 2])

„  1999 BG Mobasseri14 9/18/2015 CONTROLLING LINE TYPES We can select line styles and colors in a graph Simply pass a character string to plot –plot(t,x,’s’) For example, s=r+, puts red plus(+) marks for every data point. MATLAB accepts many other choices. Redo the exponentials using different styles

„  1999 BG Mobasseri15 9/18/2015 Homework #2 Plot the 3 exponentials on slide 8 simultaneously. –1. Use red, green and blue solid lines respectively –2. Use red plus sign(+), green star(*) and blue dots (.) for each graph

„  1999 BG Mobasseri16 9/18/2015 SPECIALIZED 2D PLOTTING FUNCTIONS For each item write an m-code to see the plots. Read the example slides bar - creates a, well, bar graph polar - creates a (  plot hist - creates a histogram of data fill - fills the curve with solid colors stairs - similar to bar but without internal lines

„  1999 BG Mobasseri17 9/18/2015 bar Usage: –bar(x,y) –plot the shape of a normal distribution given by y=exp(-x 2 ) in the range (-2,2).

„  1999 BG Mobasseri18 9/18/2015 fill Usage: –fill(x,y,’b’) where b indicates a blue fill. –plot the function exp(-t^2), in the range (-2,2)

„  1999 BG Mobasseri19 9/18/2015 polar Usage: –polar(theta,rho) Plot

„  1999 BG Mobasseri20 9/18/2015 stairs Usage –stairs(x,y) –plot the function exp(-x^2), in the range (-4,4)

„  1999 BG Mobasseri21 9/18/2015 ADDING LABELS AND TITLES There are numerous ways the appearance of a plot can be controlled. The most obvious ones are through –axis labels –figure title –legend –grid

„  1999 BG Mobasseri22 9/18/2015 LABEL USAGE axis labels –xlabel(‘time’) –ylabel(‘voltage’) Figure title –title(‘Capacitor voltage’) Legend –legend(‘first’,’second’,’third’) Grid –grid - places a grid over the plot

„  1999 BG Mobasseri23 9/18/2015 Try it!

„  1999 BG Mobasseri24 9/18/2015 Homework #3 Over a time range [-3, 3], plot the following 3 functions simultaneously using the matrix method of slide 7 –y=e -4x cos(2*pi*x);