Fondamenti di Informatica Examples: Plotting 2013/06/13

Similar documents
INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

Mechanical Engineering Department Second Year (2015)

Plotting - Practice session

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

Computing Fundamentals Plotting

Lecture 6: Plotting in MATLAB

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

PROGRAMMING WITH MATLAB WEEK 6

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

FF505/FY505 Computational Science. MATLAB Graphics. Marco Chiarandini

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

Introduction to MATLAB

PROBLEMS INVOLVING PARAMETERIZED SURFACES AND SURFACES OF REVOLUTION

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

Introduction to Matlab

YOUR MATLAB ASSIGNMENT 4

Computer Programming in MATLAB

QUICK INTRODUCTION TO MATLAB PART I

Introduction to PartSim and Matlab

Basic Graphs. Dmitry Adamskiy 16 November 2011

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

You can change the line style by adding some information in the plot command within single quotation marks.

A Tutorial on Matlab Ch. 3 Programming in Matlab

AMS 27L LAB #2 Winter 2009

Introduction to Matlab

Graphics Example a final product:

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

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

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

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

An Introduction to MATLAB II

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

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

Lecture 3 for Math 398 Section 952: Graphics in Matlab

A Brief Introduction to MATLAB

More on Plots. Dmitry Adamskiy 30 Nov 2011

PSY8219 : Week 6. Homework 5 Due Today. Homework 6 Due October 8. Readings for Today Attaway Chapter 6, 10, and 12

Programming in Mathematics. Mili I. Shah

CSE 123. Plots in MATLAB

Introduction to Matlab

ME 121 MATLAB Lesson 01 Introduction to MATLAB

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

PART 1 PROGRAMMING WITH MATHLAB

TOPIC 6 Computer application for drawing 2D Graph

MATLAB Functions and Graphics

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

MATLAB PROGRAMMING LECTURES. By Sarah Hussein

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

Dr. Iyad Jafar. Adapted from the publisher slides

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

MATLAB Quick Reference

GRAPHICS AND VISUALISATION WITH MATLAB

Introduction to MATLAB Step by Step Exercise

Introduction to MATLAB for Numerical Analysis and Mathematical Modeling. Selis Önel, PhD

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

A Quick Guide to MATLAB

Introduction to Matlab for Engineers

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

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

Graphics and plotting techniques

Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics. MathScript

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

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

MATLAB Guide to Fibonacci Numbers

Due date for the report is 23 May 2007

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

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

Basic MATLAB Intro III

workspace list the variables and describe their matrix sizes 4x1 matrix (4 rows, 1 column) x=[3.4, 7, 2.2] 1x3 matrix (1 row, 3 columns)

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

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

Finding, Starting and Using Matlab

Introduction to Computer Programming with MATLAB Matlab Fundamentals. Selis Önel, PhD

Introduction to MATLAB: Graphics

Getting Started with Matlab

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

PHS3XXX Computational Physics

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

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

Introduction to MATLAB Practical 1

INTRODUCTION TO NUMERICAL ANALYSIS

Computational Methods (PHYS 2030)

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

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

Introduction to MATLAB

MATH 2221A Mathematics Laboratory II

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

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms:

Mini-Project System Simulation over AWGN Using BPSK Modulation

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

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

Spring 2010 Instructor: Michele Merler.

1. Register an account on: using your Oxford address

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

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

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

Topic 2a MATLAB Introduction & Graphics

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

LAB 1 General MATLAB Information 1

MATLAB: A Powerful Tool for Computation and visualization

Transcription:

Fondamenti di Informatica Examples: Plotting 2013/06/13 Prof. Emiliano Casalicchio emiliano.casalicchio@uniroma2.it

Objectives This chapter presents the principles and practice of plotting in the following forms: Basic two-dimensional line plots Two-dimensional parametric plots Three-dimensional line and parametric plots Basic three-dimensional surface plots 1-2

Plot Enhancements % Listing 11-1 - Creating a subplot clf x = -2*pi:.05:2*pi; subplot(2,3,1) plot(x, sin(x)) title('1 - sin(x)'); subplot(2,3,2) plot(x, cos(x)) title('2 - cos(x)'); subplot(2,3,3) plot(x, tan(x)) title('3 - tan(x)'); subplot(2,3,4) plot(x, x.^2) title('4 - x^2'); subplot(2,3,5) plot(x, sqrt(x)) title('5 - sqrt(x)'); subplot(2,3,6) plot(x, exp(x)) title('4 - e^x'); 1-3

Functions for enhancing plots n axis n colormap n grid on/off n hold on/off n legend n shading n text n title n xlabel n ylabel 4

Multiple 2-D Plots % Listing 11-2 - Simple 2-D plots clear clc close all x = linspace(-1.5, 1.5, 30); y1 = x; y2 = x.^2; y3 = x.^3; y4 = x.^4; plot(x,y1,x,y2,x,y3,x,y4) xlabel('x') ylabel('value') title('powers of x') legend({'1','2','3','4'},... 'Location','SouthEast') 1-5

Special 2-D Effects % Listing 11-3 - Demonstrating plot options clear clc close all x = linspace(0, 2*pi); subplot(2, 3, 1) plot(x, sin(x)) axis([0 2*pi -0.5 0.5]) title('changing Data Range on an Axis') subplot(2, 3, 2) plot(x, sin(x)) hold on plot(x, cos(x)) axis tight title('multiple Plots with hold on') subplot(2, 3, 3) plot(x, sin(x),'-- ) hold on plot(x, cos(x), 'r: ) axis tight title('multiple Plots with hold on') 1-6

Special 2-D Effects % Listing 11-3 - Demonstrating plot options % Continued... subplot(2, 3, 4) N = 16; xr = linspace(0, 1, N); yr = xr + rand(1,n) - 0.5; plot(xr, yr, 'r+ ) title('symbols for Real Data') subplot(2, 3, 5) x = 0:0.01:20; y1 = 20*exp(-0.05*x).*sin(x); y2 = 0.8*exp(-0.5*x).*sin(3*x); plotyy(x,y1,x,y2,'plot'); xlabel('zero to 20 \musec. ) title('plotting on the Second Axis') subplot(2, 3, 6) pow = linspace(0, 1); w = 10.^pow; fr = complex(0, w); h = (fr.^2 + 0.1*fr + 7.5)..../ (fr.^4 + 0.12*fr.^3 + 9*fr.^2); loglog(w, abs(h)) title('log - log plots') 1-7

Transforming a Circle to an Airfoil % Listing 11-4 - Parametric plots clear clc close all th = linspace(0, 2*pi, 40); r = 1.1; g =.1; cx = sqrt(r^2-g^2) - 1; cy = g; x = r*cos(th) + cx; y = r*sin(th) + cy; plot( x, y, 'r' ) axis equal grid on hold on z = complex(x, y); w = z + 1./z; plot( real(w), imag(w), 'k' ); 1-8

2-D plot capabilities n bar(x,y) n barh(x,y) n fill(x,y,n) n hist(x,y) n loglog(x,y) n pie(y) n polar(th,y) n semilogx(x,y) n semilogy(x,y) 9

3-D View of a 2-D Plot 1-10

3-D Line plots % Listing 11-5 - % Simple 3-D line plots clear clc close all x=0:0.1:3.*pi; y1=zeros(size(x)); z1=sin(x); z2=sin(2.*x); z3=sin(3.*x); y3=ones(size(x)); y2=y3./2; plot3(x,y1,z1,'r',x,y2,z2,'b',x,y3,z3,'g ) grid on xlabel('x-axis ) ylabel('y-axis ) zlabel('z-axis') 1-11

Parametric Line Plots 1-12

Parametric Line Plots % Listing 11-6 - Linear parametric 3-D plots clear clc close all subplot(1, 2, 1) theta = 0:0.1:10.*pi; plot3(sin(theta),cos(theta),theta) title('parametric curve based on angle'); grid on 1-13

Parametric Line Plots % Listing 11-6 - Linear parametric 3-D plots subplot(1, 2, 2) N = 20; dvx = rand(1, N) - 0.5 % random v changes dvy = rand(1, N) - 0.5 dvz = rand(1, N) - 0.5 vx = cumsum(dvx); % integrate to get v vy = cumsum(dvy); vz = cumsum(dvz); x = cumsum(vx); % integrate to get pos y = cumsum(vy); z = cumsum(vz); plot3(x,y,z) grid on title('all 3 axes varying with parameter t') text(0,0,0,'start'); text(x(n),y(n),z(n),'end'); 1-14

Designing a Cube Surface plot 1-15

Cube Surfaces 1-16

Cube Surfaces % Listing 11-7 - Simple solid cube clear clc close all xx = [-1-1 1 1-1 % A-B-C-D-A -1-1 1 1-1] % D-E-F-G-D yy = [ 1-1 -1 1 1 % A-B-C-D-A 1-1 -1 1 1] % D-E-F-G-D zz = [ 1 1 1 1 1 % A-B-C-D-A -1-1 -1-1 -1] % D-E-F-G-D subplot(1, 2, 1) surf(xx, yy, zz) axis equal shading interp view(-36, 44) axis off 1-17

Cube Surfaces xx = [ 0 0 0 0 0 % P-P-P-P-P -1-1 1 1-1 % A-B-C-D-A -1-1 1 1-1 % D-E-F-G-D 0 0 0 0 0] % Q-Q-Q-Q-Q yy = [ 0 0 0 0 0 % P-P-P-P-P 1-1 -1 1 1 % A-B-C-D-A 1-1 -1 1 1 % D-E-F-G-D 0 0 0 0 0] % Q-Q-Q-Q-Q zz = [ 1 1 1 1 1 % P-P-P-P-P 1 1 1 1 1 % A-B-C-D-A -1-1 -1-1 -1 % D-E-F-G-D -1-1 -1-1 -1] % Q-Q-Q-Q-Q subplot(1, 2, 2) surf(xx, yy, zz) axis equal shading interp view(-36, 44) axis off 1-18

Simple Surface Plot % Listing 11-8 - Simple surface plot clear clc close all x=-3:3; y = x ; [xx,yy]=meshgrid(x,y); zz=xx.^2 + yy.^2; mesh(xx,yy,zz) axis tight title('z = x^2 + y^2 ) xlabel('x'),ylabel('y'),zlabel('z') 1-19

Homework n Completare il capitolo 11 studiando gli altri esempi di plotting 20

Compound Surface Plot 1-21

Using External Illumination 1-22

Designing a Cylinder Plot 1-23

Cylinder Plot 1-24

Sphere Plot 1-25

Rotating About the X Axis 1-26

Rotating About the Z Axis 1-27

Bodies of Rotation 1-28

Rotating Arbitrary Shapes 1-29

A Solid Disk 1-30

A Klein Bottle 1-31

Map of Atlanta 1-32

Summary Basic two-dimensional line plots are accomplished by using plot(x,y Two-dimensional parametric plots are accomplished by using plot(x,y), where both x and y are dependent on another independent variable Three-dimensional line and parametric plots are accomplished by using plot3(x,y,z) Basic three-dimensional surface plots are accomplished by building a plaid using meshgrid(x,y), computing the zz layer as a function of xx and yy, then plotting the surface using mesh(xx, yy, zz) or surf(xx, yy, zz) Parametric surface plots, like parametric line plots, are achieved by building the plaid with two independent variables and making xx, yy, and zz functions of those independent variables Bodies of rotation are a special case of parametric surface plots where one of the independent variables is an angle with values between 0 and 2. 1-33