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

Size: px
Start display at page:

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

Transcription

1 Lab of COMP 406 Introduction of Matlab (II) Graphics and Visualization Teaching Assistant: Pei-Yuan Zhou Contact: Lab 2: 19 Sep.,

2 Review Find the Matlab under the folder 1. Y:\Win32\Matlab\R2012a 2. Double click it and open Matlab Or open Matlab on your computer 1. Click 'Start' 2. Click 'Run' 3. Input 'nalwin32' 4. Find the Matlab under the folder /Network Application Packages/Statistical & Mathematical/Matlab 2

3 Review Matrix and Array >>a = [ ] / a=[1,2,3,4] >> a = [1 2 3; 4 5 6; ] >>z = zeros(5,1) >>a / inv(a) / a*a / a.*a / a.^3 / a^3 Calling functions >>c=sin(a) >>max(a) % a is a vector Save workspace variables >>save myfile.mat >>load myfile.mat 3

4 Outline -Graphics and Visualization 2-D Plots 3-D Plots Sub-Plots Line Plots of a Chirp, Bar Plot of a Bell Shaped Curve Stairstep Plot of a Sine Wave, Errorbar Plot Stem Plot Scatter Plot Mesh, Surface (Surfacel), Contour, Quiverm Slice 4

5 Outline 2-D Plots 3-D Plots Sub-Plots Line Plots of a Chirp, Bar Plot of a Bell Shaped Curve Stairstep Plot of a Sine Wave, Errorbar Plot Stem Plot Scatter Plot Mesh, Surface (Surfacel), Contour, Quiverm Slice 5

6 Line Plots To create two-dimensional line plots, use the plot function. For example, plot the value of the sine function from 0 to 2π: x = linspace(0,2*pi); % 100 points from 0 to 2pi y = sin (x); % calculate sin(x) plot(x,y); 6

7 Line Plots X=linspace(0,2*pi); % 100 points from 0 to 2pi plot(x,sin(x),x,cos(x),x,xin(x)+cos(x)); % multiple lines 7

8 Line Plots x = 0:pi/100:2*pi; To add plots to an existing figure, use hold on. Until you use hold off or close the window, all plots appear in the current figure window. % from 0 to 2pi, the interval between two points is pi/100 y = sin(x); plot(x,y); hold on y2 = cos(x); plot(x,y2,'r--') legend('sin','cos') xlabel('x') title('plot of the Sine and Cosine Function') 8

9 Line Plots You can label the axes and add a title. title legend label 9

10 Line Plots By adding a third input argument to the plot function, you can plot the same variables using a green star line. x = 0:0.05:7; y=log(x); plot(x,y,'g*') xlabel('x') ylabel( log(x)') title('plot of the log Function') 10

11 Line Plots of a Chirp x = 0:0.05:5; y = sin(x.^2); plot(x,y); xlabel('time') ylabel('amplitude') plot(sin((0:0.05:5).^2)). 11

12 Bar Plot of a Bell Shaped Curve x = -3:0.2:3; bar(x,exp(-x.*x)); 12

13 Stairstep Plot of a Sine Wave x = 0:0.25:10; stairs(x,sin(x)); 13

14 Errorbar Plot x = -2:0.1:2; y = erf(x); e = rand(size(x))/10; errorbar(x,y,e); The errorbar function draws a line plot of x and y values and superimposes on each observation a vertical error bar 14

15 x = 0:0.1:4; y = sin(x.^2).*exp(-x); stem(x,y) Stem Plot 15

16 Scatter Plot x = -10:0.5:10; y = x.^3; scatter(x,y,'bx'); ylabel('x-axis'); xlabel('y-axis'); doc line, doc scatter, doc line_props 16

17 Exercise Plot two functions, cos(x)+sin(x) and exp(-x) for variable x in one figure. The value of x is from 0 to pi, and the interval between two points is 0.1. Use line format --* for function 1, and --o for function 2. Provide the figure a title, legends of two functions, and Labels for x-axis and y-axis 17

18 Exercise - answer x=0:0.1:2*pi; y1=sin(x)+cos(x); y2=exp(-x); plot(x,y1,'--*',x,y2,'--o'); xlabel('time'); ylabel('value of sin(x)+cos(x) and exp(-x)'); title('function Plots of "sin(x)+cos(x)" and "exp(-x)"'); legend('sin(x)+cos(x)','exp(-x)'); 18

19 Outline 2-D Plots 3-D Plots Sub-Plots Line Plots of a Chirp, Bar Plot of a Bell Shaped Curve Stairstep Plot of a Sine Wave, Errorbar Plot Stem Plot Scatter Plot Mesh, Surface (Surfacel), Contour, Quiverm Slice 19

20 3-D Plots Three-dimensional plots typically display a surface defined by a function in two variables, z = f (x,y). To evaluate z, first create a set of (x,y) points over the domain of the function using meshgrid. Then, create a surface plot. [X,Y] = meshgrid(-2:.2:2); Z = X.* exp(-x.^2 - Y.^2); surf(x,y,z) / mesh(x,y,z) Both the surf function and its companion mesh display surfaces in three dimensions. surf displays both the connecting lines and the faces of the surface in color. mesh produces wireframe surfaces that color only the lines connecting the defining points. 20

21 Mesh Plot of Peaks z = peaks(25); mesh(z); colormap(hsv); peaks is a function to produce a 25-by-25 matrix obtained by translating and scaling Gaussian distributions, which is useful for demonstrating MESH, SURF, PCOLOR, CONTOUR, etc mesh(z) plot the colored parametrix mesh defined by matrix z. colormap is a function that sets the colormap property of a figure. See also hsv, caxis, spinmap, brighten, rgbplot, figure, colormapeditor. 21

22 Mesh Plot of Peaks z = peaks(25); mesh(z); colormap(hsv); 22

23 Surface Plot of Peaks z = peaks(25); surf(z); colormap(jet); 23

24 Surface plot with shading of peaks z = peaks(25); surfl(z); shading interp; colormap(pink); 24

25 Contour Plot of Peaks z = peaks(25); contour(z,16); colormap(hsv); contour(z) is a contour plot of matrix Z treating the values in Z as heights above a plane. * contour(z,n), draws N contour lines, overriding the automatic value. 25

26 Quiver x = -2:.2:2; y = -1:.2:1; [xx,yy] = meshgrid(x,y); % meshgrid replicates the grid vectors x and y to produce the coordinates of a rectangular grid (xx,yy) zz = xx.*exp(-xx.^2-yy.^2); [px,py] = gradient(zz); quiver(x,y,px,py,2); Plots velocity vectors as arrows with components (px,py) at the points (x,y). *And automatically scales the arrows to fit within the grid and then stretches them by 2. Use 0 to plot the arrows without the automatic scaling. 26

27 Outline 2-D Plots 3-D Plots Sub-Plots Line Plots of a Chirp, Bar Plot of a Bell Shaped Curve Stairstep Plot of a Sine Wave, Errorbar Plot Stem Plot Scatter Plot Mesh, Surface (Surfacel), Contour, Quiverm Slice 28

28 [X,Y] = meshgrid(-2:.2:2); Subplot Z = X.* exp(-x.^2 - Y.^2);%3D function You can display multiple plots in different subregions of the same window using the subplot function. subplot(2,2,1); mesh(x); title('x'); % the plot for x-axis subplot(2,2,2); mesh(y); title('y'); % the plot for y-axis subplot(2,2,3); mesh(z); title('z'); % the plot for z-axis subplot(2,2,4); mesh(x,y,z); title('x,y,z'); % the plot for the 3D function The first two inputs to the subplot function indicate the number of plots in each row and column. The third input specifies which plot is active. 29

29 Subplot 30

30 Exercise t = 0:pi/2:4*pi; [X,Y,Z] = cylinder(5*sin(t)); Plot this 3-D function into four subplots for each axis and the function. 31

31 Answer t = 0:pi/2:4*pi; [X,Y,Z] = cylinder(5*sin(t)); subplot(2,2,1); mesh(x); title('x'); subplot(2,2,2); mesh(y); title('y'); subplot(2,2,3); mesh(z); title('z'); subplot(2,2,4); mesh(x,y,z); title('x,y,z'); 32

32 Try this example Plot six functions in one window/figure, and give the title of them x=[0,2pi], y1=sin(x); y2=cos(x); y3=sin(x)+cos(x); y4=exp(x); y5=log(x); y6=x.^3 33

33 Answer x=0:pi/10:2*pi; y1=sin(x); y2=cos(x); y3=sin(x)+cos(x); y4=exp(-x); y5=log(x); y6=x.^(1/3); subplot(2,3,1); plot(y1); title('sin(x)'); subplot(2,3,2); plot(y2); title('cos(x)'); subplot(2,3,3); plot(y3); title('sin(x)+cos(x)'); subplot(2,3,4); plot(y4); title('exp(x)'); subplot(2,3,5); plot(y5); title('log(x)'); subplot(2,3,6); plot(y6); title('x^1^/^3'); 34

34 Ex 1 Please add variable A and B to Matlab workspace Create A and B. What s the transpose of A? What s the result of (A+B+10)/3? Concatenate A and B horizontally, then vertically. Subtract the 2nd row vector from A. Please clear A and B from Matlab workspace. 35

35 Ex 1 Please add variable A and B to Matlab workspace A=[ ; ; ; ]; B=A+4*j What s the transpose of A? A What s the result of (A+B+10)/3? (A + B + 10)/3 Concatenate A and B horizontally, then vertically. [A, B] [A;B] Subtract the 2nd row vector from A. A(2, :); Please clear A and B from Matlab workspace. clear 36

36 Ex 2 Make some simple plots: y = cos(x), x [0, 2π] Try to make it smoother by making the step smaller Label X-axis and Y-axis Add a title Add a legend 37

37 Ex 2 Make some simple plots: y = cos(x), x [0, 2π] x = 0:2*pi; y = cos(x); plot(x,y) Try to make it smoother by making the step smaller x = 0:0.1: 2*pi; y = cos(x); plot(x,y) Add x-axis label x-axis and y-axis label y-axis xlabel( x-axis ) ; ylabel( Y-axis ); Add a title title( The plot for function cos(x) ); Add a legend legend( cos(x) ); 38

38 Ex 2 39

39 Ex 3 Make a more complicated plot y = e -0.4x sin x, x [0,2π] Label the axes, create a nifty title and legend. Type help plot and use the information you get to make another plot of just the unconnected data points. 40

40 Ex 3 Make a more complicated plot: y = e -0.4x sin x, x [0,2π] x = 0:0.01:2*pi; y = exp(-0.4*x).*sin(x); plot(x,y) Label the axes, create a nifty title and legend. xlabel( x-axis ); ylabel( y-axis ) title( y=exp(-0.4*x)sin(x) ); legend( y=exp(-0.4*x)sin(x) ); Type help plot and use the information you get to make another plot of just the unconnected data points. plot(x, y, : ) / plot (x,y, -- ) 41

41 Ex 3 Make a 3-dimensional plot of the helix x = sin t, y = cos t, z = t. Hint: Create the vectors t, x, y, and z, then use the command plot3(x,y,z). t = 0:0.01:2*pi; x = sin(t); y = cos(t); z = t; plot3(x, y, z); grid on; 42

42 What We have Learned? 1. 2-D Plot 2. 3-D Plot 3. Sub-Plot 43

43 Contact: Lab 2: 19 Sep.,

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB 1 INTRODUCTION TO MATLAB PLOTTING WITH MATLAB Plotting with MATLAB x-y plot Plotting with MATLAB MATLAB contains many powerful functions for easily creating plots of several different types. Command plot(x,y)

More information

CSE 123. Plots in MATLAB

CSE 123. Plots in MATLAB CSE 123 Plots in MATLAB Easiest way to plot Syntax: ezplot(fun) ezplot(fun,[min,max]) ezplot(fun2) ezplot(fun2,[xmin,xmax,ymin,ymax]) ezplot(fun) plots the expression fun(x) over the default domain -2pi

More information

Mechanical Engineering Department Second Year (2015)

Mechanical Engineering Department Second Year (2015) Lecture 7: Graphs Basic Plotting MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and printing these graphs. This section describes a few of the most

More information

GRAPHICS AND VISUALISATION WITH MATLAB

GRAPHICS AND VISUALISATION WITH MATLAB GRAPHICS AND VISUALISATION WITH MATLAB UNIVERSITY OF SHEFFIELD CiCS DEPARTMENT Des Ryan & Mike Griffiths September 2017 Topics 2D Graphics 3D Graphics Displaying Bit-Mapped Images Graphics with Matlab

More information

An Introduction to MATLAB II

An Introduction to MATLAB II Lab of COMP 319 An Introduction to MATLAB II Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 2: 16th Sep, 2013 1 Outline of Lab 2 Review of Lab 1 Matrix in Matlab

More information

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

Logical Subscripting: This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression. What is the answer? >> Logical Subscripting: This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression. The finite(x)is true for all finite numerical

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab By:Mohammad Sadeghi *Dr. Sajid Gul Khawaja Slides has been used partially to prepare this presentation Outline: What is Matlab? Matlab Screen Basic functions Variables, matrix, indexing

More information

Lecture 6: Plotting in MATLAB

Lecture 6: Plotting in MATLAB Lecture 6: Plotting in MATLAB Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE21: Computer Applications. See Textbook Chapter 5. A picture is worth a thousand words MATLAB allows

More information

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

INTERNATIONAL EDITION. MATLAB for Engineers. Third Edition. Holly Moore INTERNATIONAL EDITION MATLAB for Engineers Third Edition Holly Moore 5.4 Three-Dimensional Plotting Figure 5.8 Simple mesh created with a single two-dimensional matrix. 5 5 Element,5 5 The code mesh(z)

More information

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

Plotting x-y (2D) and x, y, z (3D) graphs Tutorial : 5 Date : 9/08/2016 Plotting x-y (2D) and x, y, z (3D) graphs Aim To learn to produce simple 2-Dimensional x-y and 3-Dimensional (x, y, z) graphs using SCILAB. Exercises: 1. Generate a 2D plot

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab What is Matlab? Matlab is a commercial "Matrix Laboratory" package which operates as an interactive programming environment. Matlab is available for PC's, Macintosh and UNIX systems.

More information

Graphics Example a final product:

Graphics Example a final product: Basic 2D Graphics 1 Graphics Example a final product: TITLE LEGEND YLABEL TEXT or GTEXT CURVES XLABEL 2 2-D Plotting Specify x-data and/or y-data Specify color, line style and marker symbol (Default values

More information

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

MATLAB Laboratory 09/23/10 Lecture. Chapters 5 and 9: Plotting MATLAB Laboratory 09/23/10 Lecture Chapters 5 and 9: Plotting Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu L. Oberbroeckling (Loyola University) MATLAB 09/23/10 Lecture

More information

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER BENC 2113 DENC ECADD 2532 ECADD LAB SESSION 6/7 LAB

More information

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

Graphics in MATLAB. Responsible teacher: Anatoliy Malyarenko. November 10, Abstract. Basic Plotting Commands Graphics in MATLAB Responsible teacher: Anatoliy Malyarenko November 10, 2003 Contents of the lecture: Two-dimensional graphics. Formatting graphs. Three-dimensional graphics. Specialised plots. Abstract

More information

FF505/FY505 Computational Science. MATLAB Graphics. Marco Chiarandini

FF505/FY505 Computational Science. MATLAB Graphics. Marco Chiarandini FF505/FY505 Computational Science MATLAB Marco Chiarandini (marco@imada.sdu.dk) Department of Mathematics and Computer Science (IMADA) University of Southern Denmark Outline 1. 2D Plots 3D Plots 2 Outline

More information

PROGRAMMING WITH MATLAB WEEK 6

PROGRAMMING WITH MATLAB WEEK 6 PROGRAMMING WITH MATLAB WEEK 6 Plot: Syntax: plot(x, y, r.- ) Color Marker Linestyle The line color, marker style and line style can be changed by adding a string argument. to select and delete lines

More information

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

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations What is MATLAB? It stands for MATrix LABoratory It is developed by The Mathworks, Inc (http://www.mathworks.com) It is an interactive, integrated, environment for numerical computations for symbolic computations

More information

Basic Graphs. Dmitry Adamskiy 16 November 2011

Basic Graphs. Dmitry Adamskiy 16 November 2011 Basic Graphs Dmitry Adamskiy adamskiy@cs.rhul.ac.uk 16 November 211 1 Plot Function plot(x,y): plots vector Y versus vector X X and Y must have the same size: X = [x1, x2 xn] and Y = [y1, y2,, yn] Broken

More information

3D plot of a surface in Matlab

3D plot of a surface in Matlab 3D plot of a surface in Matlab 3D plot of a surface in Matlab Create a surface of function mesh Graphics 3-D line plot Graphics 3-D contour plot Draw contours in volume slice planes For 3-D shaded surface

More information

Fondamenti di Informatica Examples: Plotting 2013/06/13

Fondamenti di Informatica Examples: Plotting 2013/06/13 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

More information

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

The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Chapter 7 Graphics Learning outcomes Label your plots Create different

More information

Lab #1 Revision to MATLAB

Lab #1 Revision to MATLAB Lab #1 Revision to MATLAB Objectives In this lab we would have a revision to MATLAB, especially the basic commands you have dealt with in analog control. 1. What Is MATLAB? MATLAB is a high-performance

More information

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

Introduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College Introduction to Matlab to Accompany Linear Algebra Douglas Hundley Department of Mathematics and Statistics Whitman College August 27, 2018 2 Contents 1 Getting Started 5 1.1 Before We Begin........................................

More information

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

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text Chapter 1 Getting Started How to Get Matlab Matlab physically resides on each of the computers in the Olin Hall labs. See your instructor if you need an account on these machines. If you are going to go

More information

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

Classes 7-8 (4 hours). Graphics in Matlab. Classes 7-8 (4 hours). Graphics in Matlab. Graphics objects are displayed in a special window that opens with the command figure. At the same time, multiple windows can be opened, each one assigned a number.

More information

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

W1005 Intro to CS and Programming in MATLAB. Plo9ng & Visualiza?on. Fall 2014 Instructor: Ilia Vovsha. hgp://www.cs.columbia. W1005 Intro to CS and Programming in MATLAB Plo9ng & Visualiza?on Fall 2014 Instructor: Ilia Vovsha hgp://www.cs.columbia.edu/~vovsha/w1005 Outline Plots (2D) Plot proper?es Figures Plots (3D) 2 2D Plots

More information

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

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name: 1 Matlab Tutorial 1- What is Matlab? Matlab is a powerful tool for almost any kind of mathematical application. It enables one to develop programs with a high degree of functionality. The user can write

More information

Dr. Iyad Jafar. Adapted from the publisher slides

Dr. Iyad Jafar. Adapted from the publisher slides Computer Applications Lab Lab 6 Plotting Chapter 5 Sections 1,2,3,8 Dr. Iyad Jafar Adapted from the publisher slides Outline xy Plotting Functions Subplots Special Plot Types Three-Dimensional Plotting

More information

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

PERI INSTITUTE OF TECHNOLOGY DEPARTMENT OF ECE TWO DAYS NATIONAL LEVEL WORKSHOP ON COMMUNICATIONS & IMAGE PROCESSING CIPM 2017 Matlab Fun - 2 Table of Contents PERI INSTITUTE OF TECHNOLOGY DEPARTMENT OF ECE TWO DAYS NATIONAL LEVEL WORKSHOP ON COMMUNICATIONS & IMAGE PROCESSING "CIPM 2017" - 2 What? Matlab can be fun... 1 Plot the Sine Function...

More information

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB? Experiment 1: Introduction to MATLAB I Introduction MATLAB, which stands for Matrix Laboratory, is a very powerful program for performing numerical and symbolic calculations, and is widely used in science

More information

Introduction to MATLAB

Introduction to MATLAB Quick Start Tutorial Introduction to MATLAB Hans-Petter Halvorsen, M.Sc. What is MATLAB? MATLAB is a tool for technical computing, computation and visualization in an integrated environment. MATLAB is

More information

A very brief Matlab introduction

A very brief Matlab introduction A very brief Matlab introduction Siniša Krajnović January 24, 2006 This is a very brief introduction to Matlab and its purpose is only to introduce students of the CFD course into Matlab. After reading

More information

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

DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab Islamic University of Gaza Faculty of Engineering Electrical Engineering Department 2012 DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab Goals for this Lab Assignment: In this lab we would have

More information

Introduction to MATLAB Step by Step Exercise

Introduction to MATLAB Step by Step Exercise Large list of exercise: start doing now! 1 35: Basic (variables, GUI, command window, basic plot, for, if, functions) 36 40: Medium (functions) 41 45: Medium (matrices) 46 51: Medium (plot) 52 55: Medium

More information

Eng Marine Production Management. Introduction to Matlab

Eng Marine Production Management. Introduction to Matlab Eng. 4061 Marine Production Management Introduction to Matlab What is Matlab? Matlab is a commercial "Matrix Laboratory" package which operates as an interactive programming environment. Matlab is available

More information

MATH 2221A Mathematics Laboratory II

MATH 2221A Mathematics Laboratory II MATH A Mathematics Laboratory II Lab Assignment 4 Name: Student ID.: In this assignment, you are asked to run MATLAB demos to see MATLAB at work. The color version of this assignment can be found in your

More information

Introduction to MATLAB: Graphics

Introduction to MATLAB: Graphics Introduction to MATLAB: Graphics Eduardo Rossi University of Pavia erossi@eco.unipv.it September 2014 Rossi Introduction to MATLAB Financial Econometrics - 2014 1 / 14 2-D Plot The command plot provides

More information

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

Math Sciences Computing Center. University ofwashington. September, Fundamentals Making Plots Printing and Saving Graphs... Introduction to Plotting with Matlab Math Sciences Computing Center University ofwashington September, 1996 Contents Fundamentals........................................... 1 Making Plots...........................................

More information

Introduction to MATLAB Practical 1

Introduction to MATLAB Practical 1 Introduction to MATLAB Practical 1 Daniel Carrera November 2016 1 Introduction I believe that the best way to learn Matlab is hands on, and I tried to design this practical that way. I assume no prior

More information

Matlab Practice Sessions

Matlab Practice Sessions Matlab Practice Sessions 1. Getting Started Startup Matlab Observe the following elements of the desktop; Command Window Current Folder Window Command History Window Workspace Window Notes: If you startup

More information

Introduction to MATLAB

Introduction to MATLAB ELG 3125 - Lab 1 Introduction to MATLAB TA: Chao Wang (cwang103@site.uottawa.ca) 2008 Fall ELG 3125 Signal and System Analysis P. 1 Do You Speak MATLAB? MATLAB - The Language of Technical Computing ELG

More information

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

Assignment :1. 1 Arithmetic Operations : Compute the following quantities ) -1. and compare with (1- 1 Arithmetic Operations : Compute the following quantities. 2 5 2 5-1 and compare with (1-1 2 5 ) -1 Assignment :1 5-1 -1. The square root x can be calculated as sqrt(x) or 3 ( 5+1) 2 x^0.5. Area=πr 2

More information

1 Introduction to Matlab

1 Introduction to Matlab 1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,

More information

Computer Programming in MATLAB

Computer Programming in MATLAB Computer Programming in MATLAB Prof. Dr. İrfan KAYMAZ Engineering Faculty Department of Mechanical Engineering Arrays in MATLAB; Vectors and Matrices Graphing Vector Generation Before graphing plots in

More information

MATLAB Functions and Graphics

MATLAB Functions and Graphics Functions and Graphics We continue our brief overview of by looking at some other areas: Functions: built-in and user defined Using M-files to store and execute statements and functions A brief overview

More information

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

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial 1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the

More information

The College of Staten Island

The College of Staten Island The College of Staten Island Department of Mathematics 0.5 0 0.5 1 1 0.5 0.5 0 0 0.5 0.5 1 1 MTH 233 Calculus III http://www.math.csi.cuny.edu/matlab/ MATLAB PROJECTS STUDENT: SECTION: INSTRUCTOR: BASIC

More information

Introduction to Programming in MATLAB

Introduction to Programming in MATLAB Introduction to Programming in MATLAB User-defined Functions Functions look exactly like scripts, but for ONE difference Functions must have a function declaration Help file Function declaration Outputs

More information

Introduction to Matlab for Engineers

Introduction to Matlab for Engineers 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

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab The purpose of this intro is to show some of Matlab s basic capabilities. Nir Gavish, 2.07 Contents Getting help Matlab development enviroment Variable definitions Mathematical operations

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab 1 Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control Using of M-File Writing User

More information

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

1 >> Lecture 4 2 >> 3 >> -- Graphics 4 >> Zheng-Liang Lu 184 / 243 1 >> Lecture 4 >> 3 >> -- Graphics 4 >> Zheng-Liang Lu 184 / 43 Introduction ˆ Engineers use graphic techniques to make the information easier to understand. ˆ With graphs, it is easy to identify trends,

More information

1. Register an account on: using your Oxford address

1. Register an account on:   using your Oxford  address 1P10a MATLAB 1.1 Introduction MATLAB stands for Matrix Laboratories. It is a tool that provides a graphical interface for numerical and symbolic computation along with a number of data analysis, simulation

More information

More on Plots. Dmitry Adamskiy 30 Nov 2011

More on Plots. Dmitry Adamskiy 30 Nov 2011 More on Plots Dmitry Adamskiy adamskiy@cs.rhul.ac.uk 3 Nov 211 1 plot3 (1) Recall that plot(x,y), plots vector Y versus vector X. plot3(x,y,z), where x, y and z are three vectors of the same length, plots

More information

Lab of COMP 406 Introduction of Matlab (III) Programming and Scripts

Lab of COMP 406 Introduction of Matlab (III) Programming and Scripts Lab of COMP 406 Introduction of Matlab (III) Programming and Scripts Teaching Assistant: Pei-Yuan Zhou Contact: cspyzhou@comp.polyu.edu.hk Lab 3: 26 Sep., 2014 1 Open Matlab 2012a Find the Matlab under

More information

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

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline MATLAB Tutorial EE351M DSP Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Kitaek Bae Outline Part I: Introduction and Overview Part II: Matrix manipulations and common functions Part III: Plots

More information

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain Introduction to Matlab By: Dr. Maher O. EL-Ghossain Outline: q What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control

More information

TOPIC 6 Computer application for drawing 2D Graph

TOPIC 6 Computer application for drawing 2D Graph YOGYAKARTA STATE UNIVERSITY MATHEMATICS AND NATURAL SCIENCES FACULTY MATHEMATICS EDUCATION STUDY PROGRAM TOPIC 6 Computer application for drawing 2D Graph Plotting Elementary Functions Suppose we wish

More information

What is Matlab? A software environment for interactive numerical computations

What is Matlab? A software environment for interactive numerical computations What is Matlab? A software environment for interactive numerical computations Examples: Matrix computations and linear algebra Solving nonlinear equations Numerical solution of differential equations Mathematical

More information

Introduction to Matlab

Introduction to Matlab What is Matlab? Introduction to Matlab Matlab is software written by a company called The Mathworks (mathworks.com), and was first created in 1984 to be a nice front end to the numerical routines created

More information

EEE161 Applied Electromagnetics Laboratory 1

EEE161 Applied Electromagnetics Laboratory 1 EEE161 Applied Electromagnetics Laboratory 1 Instructor: Dr. Milica Marković Office: Riverside Hall 3028 Email: milica@csus.edu Web:http://gaia.ecs.csus.edu/ milica This laboratory exercise will introduce

More information

Introduction to GNU-Octave

Introduction to GNU-Octave Introduction to GNU-Octave Dr. K.R. Chowdhary, Professor & Campus Director, JIETCOE JIET College of Engineering Email: kr.chowdhary@jietjodhpur.ac.in Web-Page: http://www.krchowdhary.com July 11, 2016

More information

PART 1 PROGRAMMING WITH MATHLAB

PART 1 PROGRAMMING WITH MATHLAB PART 1 PROGRAMMING WITH MATHLAB Presenter: Dr. Zalilah Sharer 2018 School of Chemical and Energy Engineering Universiti Teknologi Malaysia 23 September 2018 Programming with MATHLAB MATLAB Environment

More information

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

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed. Example 4 Printing and Plotting Matlab provides numerous print and plot options. This example illustrates the basics and provides enough detail that you can use it for typical classroom work and assignments.

More information

Introduction to MATLAB LAB 1

Introduction to MATLAB LAB 1 Introduction to MATLAB LAB 1 1 Basics of MATLAB MATrix LABoratory A super-powerful graphing calculator Matrix based numeric computation Embedded Functions Also a programming language User defined functions

More information

EE 301 Signals & Systems I MATLAB Tutorial with Questions

EE 301 Signals & Systems I MATLAB Tutorial with Questions EE 301 Signals & Systems I MATLAB Tutorial with Questions Under the content of the course EE-301, this semester, some MATLAB questions will be assigned in addition to the usual theoretical questions. This

More information

Plotting - Practice session

Plotting - Practice session Plotting - Practice session Alessandro Fanfarillo - Salvatore Filippone fanfarillo@ing.uniroma2.it May 28th, 2013 (fanfarillo@ing.uniroma2.it) Plotting May 28th, 2013 1 / 14 Plot function The basic function

More information

Matlab programming, plotting and data handling

Matlab programming, plotting and data handling Matlab programming, plotting and data handling Andreas C. Kapourani (Credit: Steve Renals & Iain Murray) 25 January 27 Introduction In this lab session, we will continue with some more sophisticated matrix

More information

MATLAB Guide to Fibonacci Numbers

MATLAB Guide to Fibonacci Numbers MATLAB Guide to Fibonacci Numbers and the Golden Ratio A Simplified Approach Peter I. Kattan Petra Books www.petrabooks.com Peter I. Kattan, PhD Correspondence about this book may be sent to the author

More information

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

Overview. Lecture 13: Graphics and Visualisation. Graphics & Visualisation 2D plotting. Graphics and visualisation of data in Matlab Overview Lecture 13: Graphics and Visualisation Graphics & Visualisation 2D plotting 1. Plots for one or multiple sets of data, logarithmic scale plots 2. Axis control & Annotation 3. Other forms of 2D

More information

Introduction to MATLAB programming: Fundamentals

Introduction to MATLAB programming: Fundamentals Introduction to MATLAB programming: Fundamentals Shan He School for Computational Science University of Birmingham Module 06-23836: Computational Modelling with MATLAB Outline Outline of Topics Why MATLAB?

More information

INTRODUCTION TO NUMERICAL ANALYSIS

INTRODUCTION TO NUMERICAL ANALYSIS INTRODUCTION TO NUMERICAL ANALYSIS Cho, Hyoung Kyu Department of Nuclear Engineering Seoul National University 0. MATLAB USAGE 1. Background MATLAB MATrix LABoratory Mathematical computations, modeling

More information

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX 1) Objective The objective of this lab is to review how to access Matlab, Simulink, and the Communications Toolbox, and to become familiar

More information

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

ENGG1811 Computing for Engineers Week 11 Part C Matlab: 2D and 3D plots ENGG1811 Computing for Engineers Week 11 Part C Matlab: 2D and 3D plots ENGG1811 UNSW, CRICOS Provider No: 00098G1 W11 slide 1 More on plotting Matlab has a lot of plotting features Won t go through them

More information

ELEN E3084: Signals and Systems Lab Lab II: Introduction to Matlab (Part II) and Elementary Signals

ELEN E3084: Signals and Systems Lab Lab II: Introduction to Matlab (Part II) and Elementary Signals ELEN E384: Signals and Systems Lab Lab II: Introduction to Matlab (Part II) and Elementary Signals 1 Introduction In the last lab you learn the basics of MATLAB, and had a brief introduction on how vectors

More information

Scientific Functions Complex Numbers

Scientific Functions Complex Numbers CNBC Matlab Mini-Course Inf and NaN 3/0 returns Inf David S. Touretzky October 2017 Day 2: More Stuff 0/0 returns NaN 3+Inf Inf/Inf 1 -Inf, -NaN 4 Scientific Functions Complex Numbers Trig: Rounding: Modular:

More information

Computing Fundamentals Plotting

Computing Fundamentals Plotting Computing Fundamentals Plotting Salvatore Filippone salvatore.filippone@uniroma2.it 2014 2015 (salvatore.filippone@uniroma2.it) Plotting 2014 2015 1 / 14 Plot function The basic function to plot something

More information

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

2D LINE PLOTS... 1 The plot() Command... 1 Labeling and Annotating Figures... 5 The subplot() Command... 7 The polarplot() Command... Contents 2D LINE PLOTS... 1 The plot() Command... 1 Labeling and Annotating Figures... 5 The subplot() Command... 7 The polarplot() Command... 9 2D LINE PLOTS One of the benefits of programming in MATLAB

More information

NatSciLab - Numerical Software Introduction to MATLAB

NatSciLab - Numerical Software Introduction to MATLAB Outline 110112 NatSciLab - Numerical Software Introduction to MATLAB Onur Oktay Jacobs University Bremen Spring 2010 Outline 1.m files 2 Programming Branching (if, switch) Loops (for, while) 3 Anonymous

More information

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)

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) An Introduction To MATLAB Lecture 3 Basic MATLAB Commands quit exit who whos quits MATLAB quits MATLAB lists all of the variables in your MATLAB workspace list the variables and describe their matrix sizes

More information

! The MATLAB language

! The MATLAB language E2.5 Signals & Systems Introduction to MATLAB! MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to -use environment. Typical

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab What is Matlab The software program called Matlab (short for MATrix LABoratory) is arguably the world standard for engineering- mainly because of its ability to do very quick prototyping.

More information

Lecture 3 for Math 398 Section 952: Graphics in Matlab

Lecture 3 for Math 398 Section 952: Graphics in Matlab Lecture 3 for Math 398 Section 952: Graphics in Matlab Thomas Shores Department of Math/Stat University of Nebraska Fall 2002 A good deal of this material comes from the text by Desmond Higman and Nicholas

More information

Spring 2010 Instructor: Michele Merler.

Spring 2010 Instructor: Michele Merler. Spring 2010 Instructor: Michele Merler http://www1.cs.columbia.edu/~mmerler/comsw3101-2.html MATLAB does not use explicit type initialization like other languages Just assign some value to a variable name,

More information

MATLAB PROGRAMMING LECTURES. By Sarah Hussein

MATLAB PROGRAMMING LECTURES. By Sarah Hussein MATLAB PROGRAMMING LECTURES By Sarah Hussein Lecture 1: Introduction to MATLAB 1.1Introduction MATLAB is a mathematical and graphical software package with numerical, graphical, and programming capabilities.

More information

Table of Contents. Basis CEMTool 7 Tutorial

Table of Contents. Basis CEMTool 7 Tutorial PREFACE CEMTool (Computer-aided Engineering & Mathematics Tool) is a useful computational tool in science and engineering. No matter what you background be it physics, chemistry, math, or engineering it

More information

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

Introduction to Matlab. WIAA Technical Workshop #2 10/20/2015 Introduction to Matlab WIAA Technical Workshop #2 10/20/2015 * This presentation is merely an introduction to some of the functions of MATLAB and is not a comprehensive review of their capabilities. **

More information

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

INC151 Electrical Engineering Software Practice. MATLAB Graphics. Dr.Wanchak Lenwari :Control System and Instrumentation Engineering, KMUTT 1 INC151 Electrical Engineering Software Practice MATLAB Graphics Dr.Wanchak Lenwari :Control System and Instrumentation Engineering, KMUTT 1 Graphical display is one of MATLAB s greatest strengths and most

More information

3 An Introductory Demonstration Execute the following command to view a quick introduction to Matlab. >> intro (Use your mouse to position windows on

3 An Introductory Demonstration Execute the following command to view a quick introduction to Matlab. >> intro (Use your mouse to position windows on Department of Electrical Engineering EE281 Introduction to MATLAB on the Region IV Computing Facilities 1 What is Matlab? Matlab is a high-performance interactive software package for scientic and enginnering

More information

STAT/MATH 395 A - PROBABILITY II UW Winter Quarter Matlab Tutorial

STAT/MATH 395 A - PROBABILITY II UW Winter Quarter Matlab Tutorial STAT/MATH 395 A - PROBABILITY II UW Winter Quarter 2016 Néhémy Lim Matlab Tutorial 1 Introduction Matlab (standing for matrix laboratory) is a high-level programming language and interactive environment

More information

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013 Lab of COMP 406 MATLAB: Quick Start Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 1: 11th Sep, 2013 1 Where is Matlab? Find the Matlab under the folder 1.

More information

Matlab Lecture 1 - Introduction to MATLAB. Five Parts of Matlab. Entering Matrices (2) - Method 1:Direct entry. Entering Matrices (1) - Magic Square

Matlab Lecture 1 - Introduction to MATLAB. Five Parts of Matlab. Entering Matrices (2) - Method 1:Direct entry. Entering Matrices (1) - Magic Square Matlab Lecture 1 - Introduction to MATLAB Five Parts of Matlab MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-touse

More information

Basic MATLAB Intro III

Basic MATLAB Intro III Basic MATLAB Intro III Plotting Here is a short example to carry out: >x=[0:.1:pi] >y1=sin(x); y2=sqrt(x); y3 = sin(x).*sqrt(x) >plot(x,y1); At this point, you should see a graph of sine. (If not, go to

More information

Finding, Starting and Using Matlab

Finding, Starting and Using Matlab Variables and Arrays Finding, Starting and Using Matlab CSC March 6 &, 9 Array: A collection of data values organized into rows and columns, and known by a single name. arr(,) Row Row Row Row 4 Col Col

More information

Lab 5: Matlab Tutorial Due Sunday, May 8 at midnight

Lab 5: Matlab Tutorial Due Sunday, May 8 at midnight Lab 5: Matlab Tutorial Due Sunday, May 8 at midnight For this final lab, you should work with a partner. You know how to do that at this point. Only one partner turns in the lab, but both of your names

More information

Introduc)on to Matlab

Introduc)on to Matlab Introduc)on to Matlab Marcus Kaiser (based on lecture notes form Vince Adams and Syed Bilal Ul Haq ) MATLAB MATrix LABoratory (started as interac)ve interface to Fortran rou)nes) Powerful, extensible,

More information

FDP on Electronic Design Tools - Computing with MATLAB 13/12/2017. A hands-on training session on. Computing with MATLAB

FDP on Electronic Design Tools - Computing with MATLAB 13/12/2017. A hands-on training session on. Computing with MATLAB A hands-on training session on Computing with MATLAB in connection with the FDP on Electronic Design Tools @ GCE Kannur 11 th 15 th December 2017 Resource Person : Dr. A. Ranjith Ram Associate Professor,

More information

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures Introduction to Octave/Matlab Deployment of Telecommunication Infrastructures 1 What is Octave? Software for numerical computations and graphics Particularly designed for matrix computations Solving equations,

More information

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

MATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations MATLAB Tutorial The following tutorial has been compiled from several resources including the online Help menu of MATLAB. It contains a list of commands that will be directly helpful for understanding

More information