Introduction to Matlab for Engineers

Similar documents
INTERNATIONAL EDITION. MATLAB for Engineers. Third Edition. Holly Moore

PROGRAMMING WITH MATLAB WEEK 6

CSE 123. Plots in MATLAB

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

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

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

Additional Plot Types and Plot Formatting

FF505/FY505 Computational Science. MATLAB Graphics. Marco Chiarandini

3D plot of a surface in Matlab

Lab of COMP 406 Introduction of Matlab (II) Graphics and Visualization

PROBLEMS INVOLVING PARAMETERIZED SURFACES AND SURFACES OF REVOLUTION

Introduction to Programming in MATLAB

Lecture 6: Plotting in MATLAB

Lecture 3 for Math 398 Section 952: Graphics in Matlab

Introduction to MATLAB: Graphics

MATH 2221A Mathematics Laboratory II

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

MATLAB basic guide to create 2D and 3D Plots. Part I Introduction

Name: Math Analytic Geometry and Calculus III - Spring Matlab Project - due on Wednesday, March 30

The College of Staten Island

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

Mechanical Engineering Department Second Year (2015)

Matlab Notes for Calculus 3. Lia Vas

Math 7 Elementary Linear Algebra PLOTS and ROTATIONS

Chapter 11. Above: Principal contraction rates calculated from GPS velocities. Visualized using MATLAB.

Introduction to MATLAB

Plotting - Practice session

Lab 6: Graphical Methods

GRAPHICS AND VISUALISATION WITH MATLAB

SGN Introduction to Matlab

Math (Spring 2009): Lecture 5 Planes. Parametric equations of curves and lines

Chapter 8 Complex Numbers & 3-D Plots

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

More on Plots. Dmitry Adamskiy 30 Nov 2011

Dr Richard Greenaway

Computing Fundamentals Plotting

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

Plotting x-y (2D) and x, y, z (3D) graphs

Chapter 2 Vectors and Graphics

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

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

Medical Image Processing using MATLAB

Solving Simultaneous Nonlinear Equations. SELİS ÖNEL, PhD

Outline. Case Study. Colormaps. Announcements. Syllabus Case Study Task 1: Animation. Each frame in animation contains. field. map.

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

INTRODUCTION TO NUMERICAL ANALYSIS

Introduction to PartSim and Matlab

Introduction to MATLAB

Problem Set 8: Complex Numbers

By Edward Grossman Edited and Updated by Mark Turner

Assignment :1. 1 Arithmetic Operations : Compute the following quantities ) -1. and compare with (1-

Line Integration in the Complex Plane

Introduction to Matlab

Contents. Implementing the QR factorization The algebraic eigenvalue problem. Applied Linear Algebra in Geoscience Using MATLAB

Functions of Several Variables

9.1 Parametric Curves

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

MATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)

MATLAB Guide to Fibonacci Numbers

Introduction to MATLAB Fall Bruno Abreu Calfa Department of Chemical Engineering Carnegie Mellon University

form are graphed in Cartesian coordinates, and are graphed in Cartesian coordinates.

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:

A Quick Guide to MATLAB

Lab 2B Parametrizing Surfaces Math 2374 University of Minnesota Questions to:

NENS 230 Assignment 4: Data Visualization

Dr. Iyad Jafar. Adapted from the publisher slides

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

1 >> Lecture 4 2 >> 3 >> -- Graphics 4 >> Zheng-Liang Lu 184 / 243

Lecturer: Keyvan Dehmamy

Fondamenti di Informatica Examples: Plotting 2013/06/13

NatSciLab - Numerical Software Introduction to MATLAB

interpolation, color, & light Outline HW I Announcements HW II--due today, 5PM HW III on the web later today

Introduction to Matlab

APPM 2460 PLOTTING IN MATLAB

Goals: Course Unit: Describing Moving Objects Different Ways of Representing Functions Vector-valued Functions, or Parametric Curves

Math 126C: Week 3 Review

Matrices and three-dimensional graphing

Modeling and Simulating Social Systems with MATLAB

WINTER 2017 ECE 102 ENGINEERING COMPUTATION STANDARD HOMEWORK #3 ECE DEPARTMENT PORTLAND STATE UNIVERSITY

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

A very brief Matlab introduction

EGR 102 Introduction to Engineering Modeling. Lab 05B Plotting

George Mason University ECE 201: Introduction to Signal Analysis Spring 2017

Introduction to MATLAB Practical 1

Page 1 of 7 E7 Spring 2009 Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Department of Civil and Environmental Engineering. Practice Midterm 01

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

Introduction to graphics

8.1 Simple Color Specifications

Topic 5-6: Parameterizing Surfaces and the Surface Elements ds and ds. Big Ideas. What We Are Doing Today... Notes. Notes. Notes

Excel Functions & Tables

Spring 2010 Instructor: Michele Merler.

Objectives. 1 Running, and Interface Layout. 2 Toolboxes, Documentation and Tutorials. 3 Basic Calculations. PS 12a Laboratory 1 Spring 2014

Introduction to MatLab. Introduction to MatLab K. Craig 1

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Introduction to Matlab

Calculus III. 1 Getting started - the basics

INTRODUCTION TO MATLAB

Computer Programming in MATLAB

Math 259 Winter Unit Test 1 Review Problems Set B

ECE 3793 Matlab Project 1

Transcription:

Introduction to Matlab for Engineers Instructor: Thai Nhan Math 111, Ohlone, Spring 2016 Introduction to Matlab for Engineers Ohlone, Spring 2016 1/19

Today s lecture 1. The subplot command 2. Logarithmic Plots 3. 3D Graphing Introduction to Matlab for Engineers Ohlone, Spring 2016 2/19

Subplot command Subplot is a method of dividing a single figure window into multiple parts. It uses the command subplot(m,n,p). This creates an m n grid of individual plots, with the specific graph shown in element p. figure(1); subplot(1,3,2);% Divides Figure 1 into 3 sections (1 row, 3 columns, position 2) plot(...); % Plot your graph in second element subplot(1,3,3); plot(...); % Plot your graph in third element Introduction to Matlab for Engineers Ohlone, Spring 2016 3/19

Logarithmic Plots We have learned the syntax plot(x,y) which generates a linear plot of vectors x and y. The x- and y-axes are divided into equally spaced intervals. Sometimes, values of a variable ranges over many orders of magnitude. So we may want to use a logarithmic scale on one or both of the axes. Logarithmic plots are useful for representing data that vary exponentially. Data can be graphed without compressing the smaller values. (Reading: Section 5.3.2, and Appendix B, Moore s textbook.) Introduction to Matlab for Engineers Ohlone, Spring 2016 4/19

Logarithmic Plots The Matlab commands for generating logarithmic plots of the vectors x and y: semilogx(x,y) a plot with a logarithmic scale (base 10) for x and a linear scale for y semilogy(x,y) a plot with a linear scale for x and a logarithmic scale (base 10) for y loglog(x,y) a plot with a logarithmic scale (base 10) for both x and y Table: Logarithmic Plots in Matlab. Introduction to Matlab for Engineers Ohlone, Spring 2016 5/19

Logarithmic Plots Download the m-file Lecture 10 loglog.m to see examples of semilog and loglog plots. Introduction to Matlab for Engineers Ohlone, Spring 2016 6/19

3D Graphing For common use, there are two types of three-dimensional graphs: curves (wires) and surfaces. Both curves and some types of surfaces require the use of parametric functions, material typically found in Calculus III. Download the m-file Lecture 10 3D plot.m to see examples for 3D plotting. (Reading: Section 5.4, Moore s textbook.) Introduction to Matlab for Engineers Ohlone, Spring 2016 7/19

3D Graphing: Curves A three-dimensional curve has one variable and three coordinates to plot the position of the points. This is called a parametric curve. The command used is plot3. For example, the following code plots the curve z(t) = (cos(t), sin(t), sin(6t)), t [0, 2π]: t=linspace(0,2*pi,64); plot3(cos(t),sin(t),sin(6*t)); Introduction to Matlab for Engineers Ohlone, Spring 2016 8/19

3D Graphing: Surfaces To create surfaces, Matlab uses a grid on the x-y plane. This is called a meshgrid. The surface is then defined in terms of this grid. The standard 3D plot command is called surf. For example: [x,y]=meshgrid(-2:0.1:2);% Create a rectangular grid in 2D surf(x,y,x.ˆ2+y.ˆ2); Introduction to Matlab for Engineers Ohlone, Spring 2016 9/19

3D Graphing: Surfaces Another 3D plot command is called mesh. Try the following and observe the difference. [x,y]=meshgrid(-2:0.1:2); mesh(x,y,x.ˆ2+y.ˆ2); Introduction to Matlab for Engineers Ohlone, Spring 2016 10/19

3D Graphing: Surfaces An alternative for surfaces is to show a surface with contour lines in the x-y plane. It uses the surfc (or meshc) command. [x,y]=meshgrid(-2:0.1:2); surfc(x,y,x.ˆ2+y.ˆ2); Introduction to Matlab for Engineers Ohlone, Spring 2016 11/19

3D Graphing: Surfaces An alternative for surfaces is to use two independent variables, say u and v, and then define the three position variables in terms of these variables. This is called a parametric surface. It still uses the surf command. [u,v]=meshgrid(0:0.1:2,0:0.1:5*pi); x=u.*cos(v); y=u.*sin(v); z=4-u.ˆ2+v.ˆ2; surf(x,y,z); Introduction to Matlab for Engineers Ohlone, Spring 2016 12/19

3D Graphing: Surfaces A nice use for parametric surfaces is to express 3 space dimensions and a fourth characteristic, say temperature. [u,v]=meshgrid(0:.1:4,0:.1:2*pi); x=u.*cos(v); y=u.*sin(v); z=4-u.ˆ2+v.ˆ2; t=4-(x-0.5).ˆ2-(y+0.75).ˆ2; surf(x,y,z,t); Introduction to Matlab for Engineers Ohlone, Spring 2016 13/19

Surf Options: Eliminate the Surface Mesh To eliminate the mesh on the surface, use the shading option. Learn more about shading, use doc or help features. [u,v]=meshgrid(0:.1:4,0:.1:2*pi); x=u.*cos(v); y=u.*sin(v); z=4-u.ˆ2+v.ˆ2; surf(x,y,z); shading interp Introduction to Matlab for Engineers Ohlone, Spring 2016 14/19

Surf Options: Colormap A colormap is a set of colors that are used for shading your surface. There are several built-in maps or you can create your own. The built-in colormaps are: lines, jet, hsv, hot, cool, spring, summer, autumn, winter. Introduction to Matlab for Engineers Ohlone, Spring 2016 15/19

Surf Options: Transparency When displaying multiple surfaces, it is often nice to have the surfaces transparent. This is done with the alpha command. [u,v]=meshgrid(-1.5:0.1:1.5,linspace(0,2*pi,64)); x=cos(v); y=sin(v); z=u; s1=surf(x,y,z); set(s1, FaceColor, Red, FaceAlpha,0.5); hold on; s2=surf(z,x,y); set(s2, FaceColor, Blue, FaceAlpha,0.5); axis ([-2 2-2 2-2 2]); Introduction to Matlab for Engineers Ohlone, Spring 2016 16/19

Comet in 2D The comet command will show a parametric 2-dimensional curve as it is being drawn. t=linspace(0,4*pi,400); x=(16-t).*cos(t); y=(16-t).*sin(t); comet(x,y,0.05); Introduction to Matlab for Engineers Ohlone, Spring 2016 17/19

Comet in 2D An astroid can be drawn by comet command as follows. t=linspace(0,2*pi,400); x=2*(cos(t)).ˆ3; y=2*(sin(t)).ˆ3; comet(x,y,0.05); Introduction to Matlab for Engineers Ohlone, Spring 2016 18/19

Comet in 3D The comet3 command will show a parametric 3-dimensional curve as it is being drawn t=linspace(0,4*pi,400); x=(16-t).*cos(t); y=(16-t).*sin(t); z=sin(4*t); comet3(x,y,z,0.05); Introduction to Matlab for Engineers Ohlone, Spring 2016 19/19