GUI Alternatives. Syntax. Description. MATLAB Function Reference plot. 2-D line plot

Similar documents
Matlab Tutorial 1: Working with variables, arrays, and plotting

PROGRAMMING WITH MATLAB WEEK 6

Graphics in MATLAB. Responsible teacher: Anatoliy Malyarenko. November 10, Abstract. Basic Plotting Commands

Logical Subscripting: This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression.

CSE 123. Plots in MATLAB

Basic Graphs. Dmitry Adamskiy 16 November 2011

Mechanical Engineering Department Second Year (2015)

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed.

fplot Syntax Description Examples Plot Symbolic Expression Plot symbolic expression or function fplot(f) fplot(f,[xmin xmax])

2D LINE PLOTS... 1 The plot() Command... 1 Labeling and Annotating Figures... 5 The subplot() Command... 7 The polarplot() Command...

Advanced Programming in MATLAB

Graphics Example a final product:

DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab

Graphics and plotting techniques

ECE 201 Matlab Lesson #2 Basic Arithmetic and Plotting. Element-by-Element Arithmetic for Vectors and Matrices

AMS 27L LAB #2 Winter 2009

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

An Introduction to MATLAB II

This module aims to introduce Precalculus high school students to the basic capabilities of Matlab by using functions. Matlab will be used in

MATLAB Introduction to MATLAB Programming

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

INC151 Electrical Engineering Software Practice. MATLAB Graphics. Dr.Wanchak Lenwari :Control System and Instrumentation Engineering, KMUTT 1

Department of Chemical Engineering ChE-101: Approaches to Chemical Engineering Problem Solving MATLAB Tutorial Vb

Basic plotting commands Types of plots Customizing plots graphically Specifying color Customizing plots programmatically Exporting figures

Part #6. A0B17MTB Matlab. Miloslav Čapek Filip Kozák, Viktor Adler, Pavel Valtr

A Guide to Using Some Basic MATLAB Functions

Introduction to Programming in MATLAB

Additional Plot Types and Plot Formatting

STAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006

Introduction to MATLAB

Interactive Computing with Matlab. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University

DATA PLOTTING WITH MATLAB

PART 1 PROGRAMMING WITH MATHLAB

What is Matlab? A software environment for interactive numerical computations

Overview. Lecture 13: Graphics and Visualisation. Graphics & Visualisation 2D plotting. Graphics and visualisation of data in Matlab

Stokes Modelling Workshop

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text

Introduction to MATLAB: Graphics

Matlab Concise Notes

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline

Lecture 6: Plotting in MATLAB

Armstrong Atlantic State University Engineering Studies MATLAB Marina 2D Plotting Primer

Math 375 Natalia Vladimirova (many ideas, examples, and excersises are borrowed from Profs. Monika Nitsche, Richard Allen, and Stephen Lau)

Computer Programming in MATLAB

The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

Dr. Iyad Jafar. Adapted from the publisher slides

W1005 Intro to CS and Programming in MATLAB. Plo9ng & Visualiza?on. Fall 2014 Instructor: Ilia Vovsha. hgp://

1 Introduction to Matlab

Computing Fundamentals Plotting

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

Introduction to MATLAB LAB 1

MATLAB Guide to Fibonacci Numbers

Plotting - Practice session

Introduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College

Prepared by: Khairul Anuar Ishak Department of Electrical, Electronic & System Engineering Faculty of Engineering Universiti Kebangsaan Malaysia

FF505/FY505 Computational Science. MATLAB Graphics. Marco Chiarandini

A MATLAB Exercise Book. Ludmila I. Kuncheva and Cameron C. Gray

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

GRAPHICS AND VISUALISATION WITH MATLAB

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens.

National Workshop on LaTeX and MATLAB for Beginners

Introduction to Matlab

MAT 275 Laboratory 1 Introduction to MATLAB

Chapter 2. MATLAB Fundamentals

Classes 7-8 (4 hours). Graphics in Matlab.

1. Register an account on: using your Oxford address

EOSC 473/573 Matlab Tutorial R. Pawlowicz with changes by M. Halverson

1 Introduction to MATLAB

ECE 202 LAB 3 ADVANCED MATLAB

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.

Introduction to MATLAB

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University

INTRODUCTION TO MATLAB

MATLAB Laboratory 09/23/10 Lecture. Chapters 5 and 9: Plotting

Plotting using Matlab. Vytautas Astromskas

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

Lab #1 Revision to MATLAB

3D plot of a surface in Matlab

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

Fall 2014 MAT 375 Numerical Methods. Introduction to Programming using MATLAB

Chapter 3: Introduction to MATLAB Programming (4 th ed.)

Math Sciences Computing Center. University ofwashington. September, Fundamentals Making Plots Printing and Saving Graphs...

EGR 102 Introduction to Engineering Modeling. Lab 05B Plotting

Chapter 2 (Part 2) MATLAB Basics. dr.dcd.h CS 101 /SJC 5th Edition 1

ENGG1811 Computing for Engineers Week 11 Part C Matlab: 2D and 3D plots

PERI INSTITUTE OF TECHNOLOGY DEPARTMENT OF ECE TWO DAYS NATIONAL LEVEL WORKSHOP ON COMMUNICATIONS & IMAGE PROCESSING "CIPM 2017" Matlab Fun - 2

Introduction to Matlab

Introduction to Matlab

Introduction to MatLab. Introduction to MatLab K. Craig 1

Chapter 8 Complex Numbers & 3-D Plots

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.

Introduction to Matlab. WIAA Technical Workshop #2 10/20/2015

MATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations

A General Introduction to Matlab

ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)

Dr Richard Greenaway

Transcription:

MATLAB Function Reference plot 2-D line plot GUI Alternatives Use the Plot Selector to graph selected variables in the Workspace Browser and the Plot Catalog, accessed from the Figure Palette. Directly manipulate graphs in plot edit mode, and modify them using the Property Editor. For details, see Using Plot Edit Mode, and The Figure Palette in the MATLAB Graphics documentation, and also Creating Graphics from the Workspace Browser in the MATLAB Desktop documentation. Syntax plot(y) plot(x1,y1,...) plot(x1,y1,linespec,...) plot(...,'propertyname',propertyvalue,...) plot(axes_handle,...) h = plot(...) hlines = plot('v6',...) Description plot(y) plots the columns of Y versus their index if Y is a real number. If Y is complex, plot(y) is equivalent to plot(real(y),imag(y)). In all other uses of plot, the imaginary component is ignored. plot(x1,y1,...) plots all lines defined by Xn versus Yn pairs. If only Xn or Yn is a matrix, the vector is plotted versus the rows or columns of the matrix, depending on whether the vector's row or column dimension matches the matrix. If Xn is a scalar and Yn is a vector, disconnected line objects are created and plotted as discrete points vertically at Xn. plot(x1,y1,linespec,...) plots all lines defined by the Xn,Yn,LineSpec triples, where LineSpec is a line specification that determines line type, marker symbol, and color of the plotted lines. You can mix triples with

symbol, and color of the plotted lines. You can mix Xn,Yn,LineSpec triples with Xn,Yn pairs: plot(x1,y1,x2,y2,linespec,x3,y3). Note See LineSpec for a list of line style, marker, and color specifiers. plot(...,'propertyname',propertyvalue,...) sets properties to the specified property values for all lineseries graphics objects created by plot. (See the "Examples" section for examples.) plot(axes_handle,...) plots into the axes with handle axes_handle instead of the current axes (gca). h = plot(...) returns a column vector of handles to lineseries graphics objects, one handle per line. Backward-Compatible Version hlines = plot('v6',...) returns the handles to line objects instead of lineseries objects. Remarks If you do not specify a color when plotting more than one line, plot automatically cycles through the colors in the order specified by the current axes ColorOrder property. After cycling through all the colors defined by ColorOrder, plot then cycles through the line styles defined in the axes LineStyleOrder property. The default LineStyleOrder property has a single entry (a solid line with no marker). Cycling Through Line Colors and Styles By default, MATLAB resets the ColorOrder and LineStyleOrder properties each time you call plot. If you want changes you make to these properties to persist, then you must define these changes as default values. For example, set(0,'defaultaxescolororder',[0 0 0],... 'DefaultAxesLineStyleOrder','- -. -- :') sets the default ColorOrder to use only the color black and sets the LineStyleOrder to use solid, dash-dot, dash-dash, and dotted line styles. Prevent Resetting of Color and Styles with hold all The option to the command prevents the and

The all option to the hold command prevents the ColorOrder and LineStyleOrder from being reset in subsequent plot commands. In the following sequence of commands, MATLAB continues to cycle through the colors defined by the axes ColorOrder property (see above). plot(rand(12,2)) hold all plot(randn(12,2)) Additional Information See Creating Line Plots and Annotating Graphs for more information on plotting. See LineSpec for more information on specifying line styles and colors. Examples Specifying the Color and Size of Markers You can also specify other line characteristics using graphics properties (see line for a description of these properties): LineWidth Specifies the width (in points) of the line. MarkerEdgeColor Specifies the color of the marker or the edge color for filled markers (circle, square, diamond, pentagram, hexagram, and the four triangles). MarkerFaceColor Specifies the color of the face of filled markers. MarkerSize Specifies the size of the marker in units of points. For example, these statements, x = -pi:pi/10:pi; y = tan(sin(x)) - sin(tan(x)); plot(x,y,'--rs','linewidth',2,... 'MarkerEdgeColor','k',... 'MarkerFaceColor','g',... 'MarkerSize',10) produce this graph.

Specifying Tick-Mark Location and Labeling You can adjust the axis tick-mark locations and the labels appearing at each tick. For example, this plot of the sine function relabels the x-axis with more meaningful values: x = -pi:.1:pi; y = sin(x); plot(x,y) set(gca,'xtick',-pi:pi/2:pi) set(gca,'xticklabel',{'-pi','-pi/2','0','pi/2','pi'}) Now add axis labels and annotate the point -pi/4, sin(-pi/4).

Adding Titles, Axis Labels, and Annotations MATLAB enables you to add axis labels and titles. For example, using the graph from the previous example, add an x- and y-axis label: xlabel('-\pi \leq \Theta \leq \pi') ylabel('sin(\theta)') title('plot of sin(\theta)') text(-pi/4,sin(-pi/4),'\leftarrow sin(-\pi\div4)',... 'HorizontalAlignment','left') Now change the line color to red by first finding the handle of the line object created by plot and then setting its Color property. In the same statement, set the LineWidth property to 2 points. set(findobj(gca,'type','line','color',[0 0 1]),... 'Color','red',... 'LineWidth',2)

See Also axis, bar, grid, hold, legend, line, LineSpec, loglog, plot3, plotyy, semilogx, semilogy, subplot, title, xlabel, xlim, ylabel, ylim, zlabel, zlim, stem See the text String property for a list of symbols and how to display them. See the Plot Editor for information on plot annotation tools in the figure window toolbar. See Basic Plots and Graphs for related functions. playshow plot (timeseries) 1984-2006 The MathWorks, Inc. Terms of Use Patents Trademarks Acknowledgments