Jason Yalim. Here we perform a few tasks to ensure a clean working environment for our script.

Size: px
Start display at page:

Download "Jason Yalim. Here we perform a few tasks to ensure a clean working environment for our script."

Transcription

1 Table of Contents Initialization... 1 Part One -- Computation... 1 Part Two -- Plotting... 5 Part Three -- Plotting Incorrectly... 7 Part Four -- Showing Output Adjacent to Code... 8 Part Five -- Creating a Table in Output... 9 Part Six -- Calling and Publishing External Functions MAT 275 Lab with Lopez and Kim Fridays, 10:30-3:50 Publishing Example Initialization Here we perform a few tasks to ensure a clean working environment for our script. clear all format compact close all Part One -- Computation This clears previous variable definitions from the workspace, preventing the use of old variables. This makes our output, if we have any, not take up as much space. This closes any old figure windows that might have been open, ensuring that the only plots/figures visible after running the script are freshly made. We will modeling the Mandelbrot fractal. The governing linear map is where is a complex initial condition. Note that. N = 60; Number of Iterations M = 3000; Size of 1-D Domain numsnp = 6; Number of Snap Shots x = linspace(-2,1,m); y = linspace(-1.5,1.5,m); [X,Y] = meshgrid( x, y ); Z0 = complex( X, Y ); count = ones( size( Z0 ) ); Z = Z0; for k = 1:N 1

2 Z = Z.^2 + Z0; c = abs(z) <= 2.; count = count + c; if ( mod(k,floor(n/numsnp)) == 0 ) Takes numsnp snapshots. colormap( [ jet() ;flipud( jet() ); ] ) imagesc(x,y,log(count)); title(strcat('iteration ', num2str(k))) snapnow; Note outer contours. count = log(count); 2

3 3

4 4

5 Part Two -- Plotting Here we plot the Mandelbrot fractal with three different methods. Note that pcolor and surf have edgecolors that are black by default, which must be changed to see details. Notice that we have specified figures for each plot. This is done so each plot actually shows up with publish. Without it, only the last plot will show. This will further be demonstrated in part 3. figure colormap( [ jet() ;flipud( jet() ); ] ) imagesc(x,y,count); title('imagesc Plot') xlabel 'x', ylabel 'y' figure colormap( [ jet() ;flipud( jet() ); ] ) h2 = pcolor(x,y,count); set( h2, 'edgecolor', 'none' ) title('pseudo Color Plot') xlabel 'x', ylabel 'y' figure colormap( [ jet() ;flipud( jet() ); ] ) h3 = surf(x,y,count); set( h3, 'edgecolor', 'none' ) title('surface Plot') xlabel 'x', ylabel 'y', zlabel 'Convergence Value' 5

6 6

7 Note how the size of the figures in the html publish are depent on the size of the figure window when publishing occurs. Their sizes can also be affected by the publishing options. Part Three -- Plotting Incorrectly Here we try to plot three graphs, but only up with one of them. This demonstrates that we need separate figure windows for plots within sections to have them successfully appear in our published output. We will attempt to plot identically as the last section, but without the figure specifications. colormap( [ jet() ;flipud( jet() ); ] ); h = imagesc(x,y,count); title('imagesc Plot') xlabel 'x', ylabel 'y' h2 = pcolor(x,y,count); set( h2, 'edgecolor', 'none' ) title('psuedo Color Plot') xlabel 'x', ylabel 'y' h3 = surf(x,y,count); set( h3, 'edgecolor', 'none' ) title('surface Plot') xlabel 'x', ylabel 'y', zlabel 'Convergence Value' 7

8 Thus MATLAB publish will only include one plot per section unless the figure command it used to create a new figure for each new plot. Part Four -- Showing Output Adjacent to Code Here we demonstrate how to include output next to its respective calling operation: A = rand(3); B = magic(3); display(a) display(b) C = A*B D = B*A A = e e e e e e e e e-01 B = C = e e e e e e e e e+00 8

9 E = A*B-B*A D = e e e e e e e e e+00 E = e e e e e e e e e+00 Part Five -- Creating a Table in Output Here we follow the style of exercises 1 and 3 from lab 3 using Runge Kutta 4 instead of Runge Kutta 1 or 2 (Euler's and Improved Euler's). Thus we will be approximating the differential equation, which has the exact solution, We will approximating with 2, 8, 32, 128, and 512 points, computing the absolute error of our approximation at $ t =.5 $, and we will compute a ratio between our errors ( which we expect to be around 4^4 = 256 ). N = (2.^(1:2:10))'; Note that this is a Column Vector M = length(n); tspan = [ 0,.5 ]; x_sol = 3 * exp( 2 * tspan() ); f 2*x; abs_err = zeros(m,1); approxx = zeros(m,1); err_rto = zeros(m,1); cell_array = { 'N', 'x(.5)', 'Error', 'Ratio' }; table_cell_array = cell( M+1,4 ); for k = 1:length(cell_array) table_cell_array{1,k} = cell_array{k}; Sets up Table Header for k = 1:M [ tt, xx ] = RK4( f, tspan, 3, N(k) ); approxx(k) = xx(); abs_err(k) = abs( xx() - x_sol ); table_cell_array{k+1,1} = N(k); Sets up First Column table_cell_array{k+1,2} = approxx(k); et c. table_cell_array{k+1,3} = abs_err(k); et c. Now we must compute the error ratio. Since comparing e5 to e5 is nonsensical, we first set its value to N/A, for not applicable. 9

10 table_cell_array{2,4} = 'N/A'; Then we compute the others as the absolute error of the previous. Since we are working with RK4, we expect these ratios to be of the order 4^4 = 256, as each level has a timestep that is a factor of four smaller, and the RK4 method is fourth order accurate, O(h^4). for k = 2:M err_rto(k) = abs_err(k-1)/abs_err(k); table_cell_array{k+1,4} = err_rto(k); This is a sufficient example of a table using a matrix format shorte table_matrix = [ N, approxx, abs_err, err_rto ]; fprintf('s\n','results for Runge Kutta 4 Displayed with Matrix') fprintf('12s 12s 12s 12s\n','N','x(.5)','Error', 'Ratio') disp(table_matrix) Results for Runge Kutta 4 Displayed with Matrix N x(.5) Error Ratio e e e e e e e e e e e e e e e e e e e+02 This is a sufficient example of a table using a cell array format shorte Results_for_Runge_Kutta_4_Table=table_cell_array Results_for_Runge_Kutta_4_Table = 'N' 'x(.5)' 'Error' 'Ratio' [ 2] [8.1250e+00] [2.9845e-02] 'N/A' [ 8] [8.1548e+00] [2.5132e-05] [1.1875e+03] [ 32] [8.1548e+00] [7.1634e-08] [3.5084e+02] [128] [8.1548e+00] [2.5952e-10] [2.7603e+02] [512] [8.1548e+00] [1.0019e-12] [2.5903e+02] This is an overly sufficient example of a table fprintf('\n') Space out example output tm = size(table_cell_array,1); tn = size(table_cell_array,2); for j = 1:tM if ( j == 1 ) fprintf('\n') for i = 1:(tN * 14) fprintf('-') fprintf('\n38s\n','results for Runge Kutta 4') for i = 1:(tN * 14) fprintf('-') 10

11 fprintf('\n') for k = 1:tN token = table_cell_array{j,k}; if ( isstr(token) ) fprintf('11s',token) else fprintf('11g',token) if ( k < tn ) fprintf(' ') if ( j == 1 ) fprintf('\n') for i = 1:(tN * 14) fprintf('-') fprintf('\n') for i = 1:(tN * 14) fprintf('-') fprintf('\n') Results for Runge Kutta N x(.5) Error Ratio N/A e e e e And thus we see that our method is indeed fourth order accurate, as when we decrease the timestep by a factor of four, our error ratio is of the order of 256. Now we include the external function file that we used, RK4.m The next section, Part Six, focuses on calling and publishing external functions. See RK4.m below: type('rk4.m') RK4.m Computes a RK4 on f over time domain tspan with initial condition y0 with N timesteps. Note that f = f(t,y). 11

12 INPUTS: f -- f = f(t,y) = y'(t) tspan -- two vector with initial time and final time as elements. y0 -- Initial condtion vector. N -- Number of points in time domain OUTPUTS: t -- time, returns time domain y -- solution vector/matrix over time domain. Is a matrix if y0 was a vector. function [t,y] = RK4( f, tspan, y0, N ) t = linspace(tspan(1), tspan(), N); h = t(2) - t(1); y = zeros( length(y0), N ); y(:,1) = y0; for k = 1:N-1 tk = t(k); yt = y(:,k); K1 = h * f( tk, yt ); K2 = h * f( tk +.5 * h, yt +.5 * K1 ); K3 = h * f( tk +.5 * h, yt +.5 * K2 ); K4 = h * f( tk + 1. * h, yt + K3 ); y(:,k+1) = y(:,k) + 1/6 * ( K1 + 2 * ( K2 + K3 ) + K4 ); Returning column vector and corresponding column solns. t = t'; y = y'; Part Six -- Calling and Publishing External Functions Here we demonstrate how to call an external function and how to include its respective code within the published output. Notice how the command type is under the function call. This produces the output of the function before printing its respective code. Finally, notice how the command type does not style the code. This means that any LaTeX or comments will not be processed by MATLAB's publishing engine. t = linspace(0,20,5000); function_example_stable_focus( t ); 12

13 function_example_stable_focus.m type( 'function_example_stable_focus.m' ) function_example_stable_focus.m INPUTS: t -- time lin space vector that specifies the existence of the dynamical solution. OUTPUTS: A figure over the time range for the parametric equation: $$ e^{-t} \langle \cos(t), \sin(t), e^t (t_{max} - t) \rangle $$ function [ z ] = function_example_stable_focus( t ) d = exp(-t); x = d.* cos(10*pi*t); y = d.* sin(10*pi*t); z = t(:-1:1); figure(1) plot3( x, y, z, 'b-' ) xlabel('x') ylabel('y') zlabel('-t') title('stable Focus') grid on 13

14 Published with MATLAB R2013b 14

Module1: Numerical Solution of Ordinary Differential Equations. Lecture 6. Higher order Runge Kutta Methods

Module1: Numerical Solution of Ordinary Differential Equations. Lecture 6. Higher order Runge Kutta Methods Module1: Numerical Solution of Ordinary Differential Equations Lecture 6 Higher order Runge Kutta Methods Keywords: higher order methods, functional evaluations, accuracy Higher order Runge Kutta Methods

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

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 Stefan Güttel September 22, 2017 Contents 1 Introduction 2 2 Matrices and Arrays 2 3 Expressions 3 4 Basic Linear Algebra commands 4 5 Graphics 5 6 Programming Scripts 6 7 Functions

More information

MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations)

MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations) MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations) In this session we look at basic numerical methods to help us understand the fundamentals of numerical approximations.

More information

MATLAB. Input/Output. CS101 lec

MATLAB. Input/Output. CS101 lec MATLAB CS101 lec24 Input/Output 2018-04-18 MATLAB Review MATLAB Review Question ( 1 2 3 4 5 6 ) How do we access 6 in this array? A A(2,1) B A(1,2) C A(3,2) D A(2,3) MATLAB Review Question ( 1 2 3 4 5

More information

LAB #8 Numerical Methods

LAB #8 Numerical Methods LAB #8 Numerical Methods Goal: The purpose of this lab is to explain how computers numerically approximate solutions to differential equations. Required tools: Matlab routine dfield ; numerical routines

More information

Math Homework 3

Math Homework 3 Math 0 - Homework 3 Due: Friday Feb. in class. Write on your paper the lab section you have registered for.. Staple the sheets together.. Solve exercise 8. of the textbook : Consider the following data:

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB The language of technical computing AM 581 Computational Laboratory Department of Applied Mechanics, IIT Madras MATLAB: technical computing language & interactive environment for

More information

MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations)

MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations) MATLAB sessions: Laboratory 3 1 MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations) In this session we look at basic numerical methods to help us understand

More information

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment What is MATLAB? MATLAB PROGRAMMING Stands for MATrix LABoratory A software built around vectors and matrices A great tool for numerical computation of mathematical problems, such as Calculus Has powerful

More information

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

Contents. Implementing the QR factorization The algebraic eigenvalue problem. Applied Linear Algebra in Geoscience Using MATLAB Applied Linear Algebra in Geoscience Using MATLAB Contents Getting Started Creating Arrays Mathematical Operations with Arrays Using Script Files and Managing Data Two-Dimensional Plots Programming in

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

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

C =

C = file:///c:/documents20and20settings/ravindra/desktop/html/exercis... 1 of 5 10/3/2008 3:17 PM Lab Exercise 2 - Matrices Hyd 510L, Fall, 2008, NM Tech Programmed by J.L. Wilson, Sept, 2008 Problem 2.1 Create

More information

MAT 275 Laboratory 1 Introduction to MATLAB

MAT 275 Laboratory 1 Introduction to MATLAB MATLAB sessions: Laboratory 1 1 MAT 275 Laboratory 1 Introduction to MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory

More information

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis Introduction to Matlab 1 Outline What is Matlab? Matlab desktop & interface Scalar variables Vectors and matrices Exercise 1 Booleans Control structures File organization User defined functions Exercise

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

ChE 400: Applied Chemical Engineering Calculations Tutorial 6: Numerical Solution of ODE Using Excel and Matlab

ChE 400: Applied Chemical Engineering Calculations Tutorial 6: Numerical Solution of ODE Using Excel and Matlab ChE 400: Applied Chemical Engineering Calculations Tutorial 6: Numerical Solution of ODE Using Excel and Matlab Tutorial 6: Numerical Solution of ODE Gerardine G. Botte This handout contains information

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

Homework Set #2-3, Math 475B

Homework Set #2-3, Math 475B Homework Set #2-3, Math 475B Part I: Matlab In the last semester you learned a number of essential features of MATLAB. 1. In this instance, you will learn to make 3D plots and contour plots of z = f(x,

More information

Chapter 8 Complex Numbers & 3-D Plots

Chapter 8 Complex Numbers & 3-D Plots EGR115 Introduction to Computing for Engineers Complex Numbers & 3-D Plots from: S.J. Chapman, MATLAB Programming for Engineers, 5 th Ed. 2016 Cengage Learning Topics Introduction: Complex Numbers & 3-D

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

Homework Set 5 (Sections )

Homework Set 5 (Sections ) Homework Set 5 (Sections.4-.6) 1. Consider the initial value problem (IVP): = 8xx yy, yy(1) = 3 a. Do 10 steps of Euler s Method, using a step size of 0.1. Write the details in the table below. Work to

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

Introduction to Simulink

Introduction to Simulink Introduction to Simulink There are several computer packages for finding solutions of differential equations, such as Maple, Mathematica, Maxima, MATLAB, etc. These systems provide both symbolic and numeric

More information

EE 350. Continuous-Time Linear Systems. Recitation 1. 1

EE 350. Continuous-Time Linear Systems. Recitation 1. 1 EE 350 Continuous-Time Linear Systems Recitation 1 Recitation 1. 1 Recitation 1 Topics MATLAB Programming Basic Operations, Built-In Functions, and Variables m-files Graphics: 2D plots EE 210 Review Branch

More information

PHS3XXX Computational Physics

PHS3XXX Computational Physics 1 PHS3XXX Computational Physics Lecturer: Mike Wheatland michael.wheatland@sydney.edu.au Lecture and lab schedule (SNH Learning Studio 4003) 1 There are 10 weeks of lectures and labs Lectures: Mon 9am

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

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

Lab of COMP 406 Introduction of Matlab (II) Graphics and Visualization Lab of COMP 406 Introduction of Matlab (II) Graphics and Visualization Teaching Assistant: Pei-Yuan Zhou Contact: cspyzhou@comp.polyu.edu.hk Lab 2: 19 Sep., 2014 1 Review Find the Matlab under the folder

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

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

Page 1 of 7 E7 Spring 2009 Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Department of Civil and Environmental Engineering. Practice Midterm 01 Page 1 of E Spring Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Practice Midterm 1 minutes pts Question Points Grade 1 4 3 6 4 16 6 1 Total Notes (a) Write your name and your SID on the top right

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

A Brief Introduction to MATLAB

A Brief Introduction to MATLAB A Brief Introduction to MATLAB MATLAB (Matrix Laboratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB was first designed for matrix computations:

More information

Matlab Handout Nancy Chen Math 19 Fall 2004

Matlab Handout Nancy Chen Math 19 Fall 2004 Matlab Handout Nancy Chen Math 19 Fall 2004 Introduction Matlab is a useful program for algorithm development, numerical computation, and data analysis and visualization. In this class you will only need

More information

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

Math 375 Natalia Vladimirova (many ideas, examples, and excersises are borrowed from Profs. Monika Nitsche, Richard Allen, and Stephen Lau) Natalia Vladimirova (many ideas, examples, and excersises are borrowed from Profs. Monika Nitsche, Richard Allen, and Stephen Lau) January 24, 2010 Starting Under windows Click on the Start menu button

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

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

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

2 T. x + 2 T. , T( x, y = 0) = T 1

2 T. x + 2 T. , T( x, y = 0) = T 1 LAB 2: Conduction with Finite Difference Method Objective: The objective of this laboratory is to introduce the basic steps needed to numerically solve a steady state two-dimensional conduction problem

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 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

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

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 Examples. (v.01, Fall 2011, Ex prepared by HP Huang; Ex prepared by Noel Baker)

Matlab Examples. (v.01, Fall 2011, Ex prepared by HP Huang; Ex prepared by Noel Baker) 1 Matlab Examples (v.01, Fall 2011, Ex. 1-50 prepared by HP Huang; Ex 51-55 prepared by Noel Baker) These examples illustrate the uses of the basic commands that will be discussed in the Matlab tutorials.

More information

Differential Equations (92.236) Listing of Matlab Lab Exercises

Differential Equations (92.236) Listing of Matlab Lab Exercises Differential Equations (92.236) Listing of Matlab Lab Exercises This page contains a summary list of the Matlab lab exercises available for this course. We will have roughly 10 12 lab sessions that highlight

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

ENGR Fall Exam 1

ENGR Fall Exam 1 ENGR 13100 Fall 2012 Exam 1 INSTRUCTIONS: Duration: 60 minutes Keep your eyes on your own work! Keep your work covered at all times! 1. Each student is responsible for following directions. Read carefully.

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

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

A Quick Tutorial on MATLAB. Zeeshan Ali

A Quick Tutorial on MATLAB. Zeeshan Ali A Quick Tutorial on MATLAB Zeeshan Ali MATLAB MATLAB is a software package for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It's name

More information

MATH2071: LAB 2: Explicit ODE methods

MATH2071: LAB 2: Explicit ODE methods MATH2071: LAB 2: Explicit ODE methods 1 Introduction Introduction Exercise 1 Euler s method review Exercise 2 The Euler Halfstep (RK2) Method Exercise 3 Runge-Kutta Methods Exercise 4 The Midpoint Method

More information

A Tutorial on Matlab Ch. 3 Programming in Matlab

A Tutorial on Matlab Ch. 3 Programming in Matlab Department of Electrical Engineering University of Arkansas A Tutorial on Matlab Ch. 3 Programming in Matlab Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Plotting M-file Scripts Functions Control Flows Exercises

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

Summer 2009 REU: Introduction to Matlab

Summer 2009 REU: Introduction to Matlab Summer 2009 REU: Introduction to Matlab Moysey Brio & Paul Dostert June 29, 2009 1 / 19 Using Matlab for the First Time Click on Matlab icon (Windows) or type >> matlab & in the terminal in Linux. Many

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

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

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

AOE 5204: Homework Assignment 4 Due: Wednesday, 9/21 in class. Extended to Friday 9/23 Online Students:

AOE 5204: Homework Assignment 4 Due: Wednesday, 9/21 in class. Extended to Friday 9/23 Online Students: AOE 5204: Homework Assignment 4 Due: Wednesday, 9/21 in class. Extended to Friday 9/23 Online Students: Email (cdhall@vt.edu) by 5 PM Suppose F b is initially aligned with F i and at t = 0 begins to rotate

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

Numerical Methods in Engineering Sciences

Numerical Methods in Engineering Sciences Numerical Methods in Engineering Sciences Lecture 1: Brief introduction to MATLAB Pablo Antolin pablo.antolinsanchez@unipv.it October 29th 2013 How many of you have used MATLAB before? How many of you

More information

Homework #5. Plot labeled contour lines of the stresses below and report on how you checked your plot (see page 2):

Homework #5. Plot labeled contour lines of the stresses below and report on how you checked your plot (see page 2): Homework #5 Use the equations for a plate under a uniaxial tension with a hole to model the stresses in the plate. Use a unit value for the tension (i.e., Sxx infinity = 1), let the radius "a" of the hole

More information

Workpackage 5 - Ordinary Differential Equations

Workpackage 5 - Ordinary Differential Equations Mathematics for I Workpackage 5 - Ordinary Differential Equations Introduction During this laboratory you will be introduced to some of Matlab s facilities for solving ordinary differential equations (ode).

More information

EGR 102 Introduction to Engineering Modeling. Lab 05B Plotting

EGR 102 Introduction to Engineering Modeling. Lab 05B Plotting EGR 102 Introduction to Engineering Modeling Lab 05B Plotting 1 Overview Plotting in MATLAB 2D plotting ( ezplot(), fplot(), plot()) Formatting of 2D plots 3D plotting (surf(), mesh(), plot3()) Formatting

More information

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab MATH 495.3 (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab Below is a screen similar to what you should see when you open Matlab. The command window is the large box to the right containing the

More information

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen.

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen. University of Illinois at Urbana-Champaign Department of Electrical and Computer Engineering ECE 298JA Fall 2015 Matlab Tutorial 1 Overview The goal of this tutorial is to help you get familiar with MATLAB

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Violeta Ivanova, Ph.D. MIT Academic Computing violeta@mit.edu http://web.mit.edu/violeta/www/iap2006 Topics MATLAB Interface and Basics Linear Algebra and Calculus Graphics Programming

More information

37 Self-Assessment. 38 Two-stage Runge-Kutta Methods. Chapter 10 Runge Kutta Methods

37 Self-Assessment. 38 Two-stage Runge-Kutta Methods. Chapter 10 Runge Kutta Methods Chapter 10 Runge Kutta Methods In the previous lectures, we have concentrated on multi-step methods. However, another powerful set of methods are known as multi-stage methods. Perhaps the best known of

More information

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

Matlab Tutorial 1: Working with variables, arrays, and plotting Matlab Tutorial 1: Working with variables, arrays, and plotting Setting up Matlab First of all, let's make sure we all have the same layout of the different windows in Matlab. Go to Home Layout Default.

More information

Good luck! First name Legi number Computer slabhg Points

Good luck! First name Legi number Computer slabhg Points Surname First name Legi number Computer slabhg... Note 1 2 4 5 Points Fill in the cover sheet. (Computer: write the number of the PC as printed on the table). Leave your Legi on the table. Switch off your

More information

Signals and Systems Profs. Byron Yu and Pulkit Grover Fall Homework 1

Signals and Systems Profs. Byron Yu and Pulkit Grover Fall Homework 1 18-290 Signals and Systems Profs. Byron Yu and Pulkit Grover Fall 2018 Homework 1 This homework is due in class on Thursday, September 6, 9:00am. Instructions Solve all non-matlab problems using only paper

More information

Num. #1: Recalls on Numerical Methods for Linear Systems and Ordinary differential equations (ODEs) - CORRECTION

Num. #1: Recalls on Numerical Methods for Linear Systems and Ordinary differential equations (ODEs) - CORRECTION Num. #1: Recalls on Numerical Methods for Linear Systems and Ordinary differential equations (ODEs) - CORRECTION The programs are written with the SCILAB software. 1 Resolution of a linear system & Computation

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

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MATLAB sessions: Laboratory MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs

More information

MATLAB in the Biosciences - Exercise Solutions

MATLAB in the Biosciences - Exercise Solutions MATLAB in the Biosciences - Exercise Solutions Sven Mesecke Sep 2013 Exercise 1 % there are several ways for creating these arrays % 1 - squared brackets A = [1 3 5; 3 6 3; 9 8 5] % 2 - functions for array

More information

Complex Dynamic Systems

Complex Dynamic Systems Complex Dynamic Systems Department of Information Engineering and Mathematics University of Siena (Italy) (mocenni at dii.unisi.it) (madeo at dii.unisi.it) (roberto.zingone at unisi.it) Lab Session #1

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

A Guide to Using Some Basic MATLAB Functions

A Guide to Using Some Basic MATLAB Functions A Guide to Using Some Basic MATLAB Functions UNC Charlotte Robert W. Cox This document provides a brief overview of some of the essential MATLAB functionality. More thorough descriptions are available

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

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

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation CDA5530: Performance Models of Computers and Networks Chapter 8: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted

More information

PROBLEMS INVOLVING PARAMETERIZED SURFACES AND SURFACES OF REVOLUTION

PROBLEMS INVOLVING PARAMETERIZED SURFACES AND SURFACES OF REVOLUTION PROBLEMS INVOLVING PARAMETERIZED SURFACES AND SURFACES OF REVOLUTION Exercise 7.1 Plot the portion of the parabolic cylinder z = 4 - x^2 that lies in the first octant with 0 y 4. (Use parameters x and

More information

LAB 1 General MATLAB Information 1

LAB 1 General MATLAB Information 1 LAB 1 General MATLAB Information 1 General: To enter a matrix: > type the entries between square brackets, [...] > enter it by rows with elements separated by a space or comma > rows are terminated by

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

over The idea is to construct an algorithm to solve the IVP ODE (8.1)

over The idea is to construct an algorithm to solve the IVP ODE (8.1) Runge- Ku(a Methods Review of Heun s Method (Deriva:on from Integra:on) The idea is to construct an algorithm to solve the IVP ODE (8.1) over To obtain the solution point we can use the fundamental theorem

More information

MATH 308, Summer Examples in MATLAB

MATH 308, Summer Examples in MATLAB MATH 308, Summer 2016 Examples in MATLAB % % %% % %% % Plotting a function % % %% % %% % %% % %% % %% % %% % %% % figure(1) clear t % Anonymous Functions u7=@(t) 0198*exp(-08590*t) + 00014*exp(-29142*t)

More information

6 Appendix B: Quick Guide to MATLAB R

6 Appendix B: Quick Guide to MATLAB R 6 Appendix B: Quick Guide to MATLAB R 6.1 Introduction In this course we will be using the software package MATLAB R. Version 17.12.0, Release R2011a has been installed in Foster 100, the labs on the third

More information

Mathematics for chemical engineers

Mathematics for chemical engineers Mathematics for chemical engineers Drahoslava Janovská Department of mathematics Winter semester 2013-2014 Numerical solution of ordinary differential equations Initial value problem Outline 1 Introduction

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

YOUR MATLAB ASSIGNMENT 4

YOUR MATLAB ASSIGNMENT 4 YOUR MATLAB ASSIGNMENT 4 Contents GOAL: USING MATLAB TO SKETCH THE GRAPHS OF A PARAMETERIZED SURFACES IN SPACE USE THE FOLLOWING STEPS: HERE IS AN ACTUAL EXAMPLE OF A CLOSED SURFACE DRAWN PARAMETERICALLY

More information

MAT 343 Laboratory 2 Solving systems in MATLAB and simple programming

MAT 343 Laboratory 2 Solving systems in MATLAB and simple programming MAT 343 Laboratory 2 Solving systems in MATLAB and simple programming In this laboratory session we will learn how to 1. Solve linear systems with MATLAB 2. Create M-files with simple MATLAB codes Backslash

More information

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

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are

More information

7.1 First-order initial-value problems

7.1 First-order initial-value problems 7.1 First-order initial-value problems A first-order initial-value problem (IVP) is a first-order ordinary differential equation with a specified value: d dt y t y a y f t, y t That is, this says that

More information

MATLAB and Numerical Analysis

MATLAB and Numerical Analysis School of Mechanical Engineering Pusan National University dongwoonkim@pusan.ac.kr Teaching Assistant 김동운 dongwoonkim@pusan.ac.kr 윤종희 jongheeyun@pusan.ac.kr Lab office: 통합기계관 120호 ( 510-3921) 방사선영상연구실홈페이지

More information

Homework 14 solutions

Homework 14 solutions Section 9.1: Ex 1,5,10,15,16 Section 9.: Ex 1,8,9; AP 1-5,9 Section 9.3: AP 1-5 Section 9.1 Homework 14 solutions 1. (a) Show that y( is a solution to the differential equation by substitution. (b) Find

More information

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano MATLAB Lesson I Chiara Lelli Politecnico di Milano October 2, 2012 MATLAB MATLAB (MATrix LABoratory) is an interactive software system for: scientific computing statistical analysis vector and matrix computations

More information

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

Introduction to MATLAB for Numerical Analysis and Mathematical Modeling. Selis Önel, PhD Introduction to MATLAB for Numerical Analysis and Mathematical Modeling Selis Önel, PhD Advantages over other programs Contains large number of functions that access numerical libraries (LINPACK, EISPACK)

More information

MATLAB Tutorial. Primary Author: Shoumik Chatterjee Secondary Author: Dr. Chuan Li

MATLAB Tutorial. Primary Author: Shoumik Chatterjee Secondary Author: Dr. Chuan Li MATLAB Tutorial Primary Author: Shoumik Chatterjee Secondary Author: Dr. Chuan Li 1 Table of Contents Section 1: Accessing MATLAB using RamCloud server...3 Section 2: MATLAB GUI Basics. 6 Section 3: MATLAB

More information

MATLAB/Octave Tutorial

MATLAB/Octave Tutorial University of Illinois at Urbana-Champaign Department of Electrical and Computer Engineering ECE 298JA Fall 2017 MATLAB/Octave Tutorial 1 Overview The goal of this tutorial is to help you get familiar

More information

No, not unless you specify in MATLAB which folder directory to look for it in, which is outside of the scope of this course.

No, not unless you specify in MATLAB which folder directory to look for it in, which is outside of the scope of this course. ENGR 1181 Midterm 2 Review Worksheet SOLUTIONS Note: This practice material does not contain actual test questions or represent the format of the midterm. The first 29 questions should be completed WITHOUT

More information