1.1 ABOUT MATLAB and MATLAB GUI (Graphical User Interface)

Size: px
Start display at page:

Download "1.1 ABOUT MATLAB and MATLAB GUI (Graphical User Interface)"

Transcription

1 Chapter 1 Introduction The Taylor Series is one of the most important tools in numerical analysis. It constitutes the foundation of numerical methods and will be used in most of the chapters of this text. From the Taylor Series, we can derive the formulas and error estimates of the many numerical techniques used. This chapter contains a review of the Taylor Series, and a brief introduction to MATLAB R. 1.1 ABOUT MATLAB and MATLAB GUI (Graphical User Interface) MATLAB (MATrix LABoratory) is a powerful interactive system for matrixbased computation designed for scientific and engineering use. It is good for many forms of numeric computation and visualization. MATLAB language is a highlevel matrix/array language with control flow statements, functions, data structures, input/output, and object-oriented programming features. To fully use the power and computing capabilities of this software program in classrooms and laboratories by teachers and students in science and engineering, part of this text is inted to introduce the computational power of MATLAB to modern numerical methods. MATLAB has several advantages. There are three major elements that have contributed to its immense popularity. First, it is extremely easy to use since data can be easily entered, especially for algorithms that are adaptable to a table format. This is an important feature because it allows students to experiment with many numerical problems in a short period of time. Second, it includes highlevel commands for two-dimensional and three-dimensional data visualization, and presentation graphics. Plots are easily obtained from within a script or in command mode. Third, the most evident power of a MATLAB is its speed of calculation. The program gives instantaneous feedback. Because of their popularity, MATLAB and other software such as MAPLE and Mathematica are now available in most university microcomputer laboratories. One of the primary objectives of this text is to give students a clear step-by-step explanation of the algorithm corresponding to each numerical method used. To 1

2 2 INTRODUCTION accomplish this objective, we have developed MATLAB M-functions contained in a supplementary CD-ROM at the back of the book. These M-files can be used for the application or illustration of all numerical methods discussed in this text. Each M-function will enable students to solve numerical problems simply by entering data and executing the M-functions. It is well known that the best way to learn computer programming is to write computer programs. Therefore, we believe that by understanding the basic theory underlying each numerical method and the algorithm behind it, students will have the necessary tools to write their own programs in a high-level computer language such as C or FORTRAN. Another future of MATLAB is that it provides the Graphical User Interface (GUI). It is a pictorial interface to a program inted to provide students with a familiar environment in which to work. This environment contains push buttons, toggle buttons, lists, menus, text boxes, and so forth, all of which are already familiar to the user, so that they can concentrate on using the application rather than on the mechanics involved in doing things. They do not have to type commands at the command line to run the MATLAB functions. For this reason, we introduced GUI in this edition to make it easier for the students to run the M-functions of the book. A readme file named SUN Package readme contained in the directory NMETH of the CD attached at the back cover of the book, explains in details the steps to follow to run the MATLAB functions using GUI. In addition, Appix D shows the use of GUI for solving several examples. 1.2 ANINTRODUCTIONTOMATLAB In this section we give to the reader a brief tutorial introduction to MATLAB. For additional information we urge the reader to use the reference and user s guides of MATLAB Matrices and matrix computation MATLAB treats all variables as matrices. They are assigned to expressions by using an equal sign and their names are case-sensitive. For example, >> A = [4-2 5; 6 1 7; ] A= New rows may be indicated by a new line or by a semicolon. A column vector may be given as >> x=[2;8;9]orx=[2 8 9] x=

3 AN INTRODUCTION TO MATLAB Elements of the matrix can be a number or an expression, like >> x = [ /4 2^3] x= One can define an array with a particular structure by using the command As an example x=a:step:b >> y = [0: 0.2 : 1] y= >> y=[0: pi/3:pi] y= >> y = [20: -5 : 2] y= MATLAB has a number of special matrices that can be generated by built-in functions >> ones(2) a matrix of all 1 s. >> zeros(2,4) a2 4 matrix of zeros. >> rand(2,4)

4 4 INTRODUCTION a2 4 random matrix with uniformly distributed random elements. >> eyes(3) the 3 3identitymatrix. The diag function either creates a matrix with specified values on a diagonal or extracts the diagonal entries. For example, >> v=[325]; >> D=diag(v) D= a3 3 diagonal matrix with v on the main diagonal. To extract the diagonal entries of an existing matrix, the diag function is used: >> C=[2-47;318;-156]; >> u=diag(c) u= The linspace function generates row vectors with equally spaced elements. The form of the function is linspace(firstvalue, lastvalue, numvalues) where firstvalue and lastvalue are the starting and ing values in the sequence of elements and NumValues is the number of elements to be created. For example, >> evens = linspace(0,10,6) evens = The most useful matrix functions are

5 AN INTRODUCTION TO MATLAB 5 eig inv lu qr rank eigenvalues and eigenvectors inverse LU decomposition QR factorization rank A component-by-component addition of two vectors of the same dimensions is indicated as >> x = [1 5 8]; >> y = [2 4 3]; >> x+y Multiplying a vector or matrix by a scalar will scale each element of the vector or matrix by the value of the scalar. >> C = 2*[1 3; 4 2] C= >> v = 3*[ ] v= The component-by-component multiplication of the vectors x and y is indicated as >> x. * y The inner, or dot, product of two vectors is a scaler and can be obtained by multiplying a row vector and a column vector. For example, >> u=[ ]; v=[2; 3; 10; 5]; >> u*v 31

6 6 INTRODUCTION The transpose of a matrix or a vector is denoted by a prime symbol. For example >> x The matrix operations of multiplication, power, and division are indicated as >> B = [1 3; 4 2]; >> A = [2 5; 0 6]; >> A*B >> A^ >> A/B >> A.*B Note that the three operations of multiplication, division, and power can operate elementwise by preceding them with a period Polynomials MATLAB provides a number of useful built-in functions that operates on polynomials. The coefficients of a polynomial are specified by the entries of a vector. For example, the polynomial p(x) =2x 3 5x is specified by [ ]. To evaluate the polynomial at a given x we use the polyval function. >> c=[2-508]; >> polyval(c,2)

7 AN INTRODUCTION TO MATLAB 7 4 evaluates the polynomials p(x) =2x 3 5x 2 +8atx =2. The function roots finds the n roots of a polynomial of degree n. For example, to find the roots of the polynomial p(x) =x 3 5x 2 17x + 21, enter >> a = [ ]; >> roots(a) Output format While all computations in MATLAB are performed in double precision, the format of the displayed output can be controlled by the following commands: format short format long format short e format long e format rat fixed point with 4 decimal places (the default) fixed point with 14 decimal places scientific notation with 4 decimal places scientific notation with 15 decimal places approximation by ratio of small integers Once invoked, the chosen format remains in effect until changed. It is possible to make the printed output from a MATLAB function look good by using the disp and fprintf functions. disp(x) displays the array X, without printing the array name. If X is a string, the text is displayed. For example, disp( The input matrix A is ) will display the text placed in single quotes. The function disp also allows us to print numerical values placed in text strings. For example, disp([ Newton s method converges after,num2str(iter), iterations ]) will write on the screen Newton s method converges after 9 iterations. Here the function num2str(iter) converts a number to a string. The other function fprintf is more flexible and has the form

8 8 INTRODUCTION fprintf( filename, format,list) where filename is optional; if it is omitted, output goes to the screen. format is a format control string containing conversion specifications or any optional text. The conversion specifications control the output of array elements. Common conversion specifications include: %P.Qe %P.Qf %P.Qg for exponential fixed point to automatically select the shorter of %P.Qe or %P.Qf where P and Q are integers that set the field width and the number of decimal places, respectively. list is a list of variable names separated by commas, and the special format \n produces a new line. For example, the statements >> x=pi;y=4.679;z=9; >> fprintf( \n x = %8.7f\n y=%4.3f\n z = %1.0f\n,x,y,z) prints on the screen x = y = z= Planar plots Plotting functions is very easy in MATLAB. Graphs of two-dimensional functions can be generated by using the MATLAB command plot. You can, for example, plot the function y = x over the interval [ 1, 2] with the following commands: >> x = [-1: 0.02: 2]; >> y=x.ˆ2 +1; >> plot(x,y) The plot is shown in Figure 1.1. The command plot(x,y, r+: ) will result in r=red with + for points and dotted line. Use help plot for many options. To plot a function f1 defined by an M-file (see Subsection 1.2.7) in an interval [a, b], we use the command >> fplot( f1,[a,b]).

9 AN INTRODUCTION TO MATLAB FIGURE 1.1 Plot of the function f(x) =x 2 +1 in [ 1, 2]. Other features can be added to a given graph using commands such as grid, xlabel, ylabel, title, etc... For example, the command grid on will create grid lines on the graph. Plots of parametrically defined curves can also be made. Try, for example, t=[0: 0.01: 4*pi]; x=cos(2*t); y=sin(3*t); plot(x,y). Multiple plots on a single graph are illustrated by >> x=[0:0.1:2*pi]; >> y1=cos(x); y2=sin(x); y3=cos(2*x); >> plot(x,y1,x,y2,x,y3) D mesh plots Three-dimensional or 3-D mesh surface plots are drawn with the function mesh. The command mesh(z) creates a three-dimensional perspective plot of the elements of the matrix z. The following example will generate the plot shown in Figure 1.2 of the function z = e x2 y 2 over the square [ 4, 4] [ 4, 4]. >> [x y]=meshgrid(-4.0:0.2:4.0,-4.0:0.2:4.0); >> z=exp(-x.^2-y.^2); >> mesh(x,y,z) The first command creates a matrix whose entries are the points of a grid in

10 10 INTRODUCTION FIGURE 1.2 Three-dimensional surface. the square 4 x 4, 4 y 4 with grid 0.2 units wide and 0.2 units tall. The second command creates a matrix whose entries are the values of the function z(x, y) at the grid points. The third command uses this information to construct the graph. Other commands related to 3-D graphics are plot3 and surf Function files MATLAB contains a vast collection of built-in functions from elementary functions like sine and cosine, to more sophisticated functions like matrix inversions, matrix eigenvalues, and fast Fourier transforms. Table 1.1 contains a small selection of elementary mathematical MATLAB functions and Appix B contains additional lists of functions grouped by subject area. Note that all these function names must be in lower cases. MATLAB functions may have single or multiple arguments. For example, [U,D]=eig(A) produces a matrix U whose columns are the eigenvectors of A and a diagonal matrix D with the eigenvalues of A on its diagonal Defining functions MATLAB allows users to define their own functions by constructing an M-file in the M-file Editor/Debugger. The first line of a function has the form

11 AN INTRODUCTION TO MATLAB 11 cos(x) sin(x) tan(x) sqrt(x) abs(x) exp(x) log(x) log10(x) cosh(x) tanh(x) asin(x) expm(a) cosine of x sine of x tangent of x square root of x absolute value of x exponential of x log to the base e of x log to the base 10 of x hyperbolic cosine of x hyperbolic tangent of x inverse sine function of x exponential of matrix A Table 1.1 Elementary mathematical MATLAB functions. function y = function name(input arguments) As an example, let us define the function f1(x) =2x 3 3x + 1 as an m.file. Using the Editor/Debugger or any text editor like emacs, or vi, we enter function y=f1(x) y=2*x.ˆ3-3*x+1; Once this function is saved as an M-file named f1.m, we can use the MATLAB command window to compute, for example, >> f1(2) 11 User defined functions can themselves have functions as input parameters. They can be evaluated internally by using the function feval. For example, >> x1=fzero( f1,0) x1= gives the zero of f1 closest to 0. We can pass one function f1.m to another function f2.m in MATLAB by using symbol: >> f2(@f1) For example, the built-in function quad(f,a,b) in MATLAB approximately integrates the function y = f(x) froma to b. To use this built-in function to approximately integrate y =cos(πx) +2 from x = 1 tox = 1, we begin by writing a

12 12 INTRODUCTION MATLAB function called f1.m: function y=f1(x) y=cos(pi*x)+2; If we are in the correct directory, we type in MATLAB: >> Relations and loops Like most computer languages, MATLAB offers a variety of flow control statements like for, while, andif. The statements, that we use to control the flow are called relations. The Relational operators in MATLAB are == equal <= less than or equal >= greater than or equal = notequal < less than > greater than Note that = is used in an assignment statement while == is used in a relation. Logical operators & and or not if, for, while statements The general form of an if statement is if <if expression> <statements> elseif <if expression> <statements>... else

13 AN INTRODUCTION TO MATLAB 13 <statements> Here is a simple example. If i, j =1,..., 10, then if i==j A(i,j)=1; else A(i,j)=0; will result in a diagonal matrix A with 1 s in its diagonal. The general form of a for loop is for <loop variable= loop expression> <statements> For example, S=0; for i=1:100 S=S+1; S results in the output S= 100 You can also nest for statements. Hilbert matrix, H. The following statements create an m n for i=1:m for j=1:n H(i,j)=1/(i+j-1); The switch command is ideal for decision making. The general form of the switch command is switch switch expression case case-expression commands

14 14 INTRODUCTION... otherwise commands Here is a code that finds the number of days in a month. For simplicity we will ignore the effect of leap years on the number of days in February and assume that there are always 28 days in February. The switch command is ideal for this kind of code. We implement it as follows: switch month case {1,3,5,7,8,10,12} days = 31; case {4,6,9,11} days = 30; case 2 days = 28; The variable month carries the number of the month, and deping on its value the first case, second case, or third case will be executed deping on the outcome of comparing the switch expression (month) to the members of the various case expressions. The same result could also have been accomplished with an if-structure, but in this case the switch-command resulted in a more compact and elegant code. Finally, MATLAB also has its own version of the while loop, which repeatedly executes a group of statements while a condition remains true. Its form is while < while expression > < condition statements> Given a positive number n the following statements compute and display the even powers of 3 less than n. k=0; while 3^k < n if rem(k,2)==0 3^k k=k+1; else k=k+1;

Chapter 1 Introduction to MATLAB

Chapter 1 Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 What is MATLAB? MATLAB = MATrix LABoratory, the language of technical computing, modeling and simulation, data analysis and processing, visualization and graphics,

More information

2.0 MATLAB Fundamentals

2.0 MATLAB Fundamentals 2.0 MATLAB Fundamentals 2.1 INTRODUCTION MATLAB is a computer program for computing scientific and engineering problems that can be expressed in mathematical form. The name MATLAB stands for MATrix LABoratory,

More information

Introduction to MatLab. Introduction to MatLab K. Craig 1

Introduction to MatLab. Introduction to MatLab K. Craig 1 Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations

More information

MATLAB QUICK START TUTORIAL

MATLAB QUICK START TUTORIAL MATLAB QUICK START TUTORIAL This tutorial is a brief introduction to MATLAB which is considered one of the most powerful languages of technical computing. In the following sections, the basic knowledge

More information

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

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms: Appendix A Basic MATLAB Tutorial Extracted from: http://www1.gantep.edu.tr/ bingul/ep375 http://www.mathworks.com/products/matlab A.1 Introduction This is a basic tutorial for the MATLAB program which

More information

MATLAB NOTES. Matlab designed for numerical computing. Strongly oriented towards use of arrays, one and two dimensional.

MATLAB NOTES. Matlab designed for numerical computing. Strongly oriented towards use of arrays, one and two dimensional. MATLAB NOTES Matlab designed for numerical computing. Strongly oriented towards use of arrays, one and two dimensional. Excellent graphics that are easy to use. Powerful interactive facilities; and programs

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

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

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Ordinary Differential Equation Solver Language (ODESL) Reference Manual Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE

More information

BEGINNING MATLAB. R.K. Beatson Mathematics Department University of Canterbury. 2 Matlab as a simple matrix calculator 2

BEGINNING MATLAB. R.K. Beatson Mathematics Department University of Canterbury. 2 Matlab as a simple matrix calculator 2 BEGINNING MATLAB R.K. Beatson Mathematics Department University of Canterbury Contents 1 Getting started 1 2 Matlab as a simple matrix calculator 2 3 Repeated commands 4 4 Subscripting, rows, columns and

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

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

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

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Kristian Sandberg Department of Applied Mathematics University of Colorado Goal The goal with this worksheet is to give a brief introduction to the mathematical software Matlab.

More information

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

Prof. Manoochehr Shirzaei. RaTlab.asu.edu RaTlab.asu.edu Introduction To MATLAB Introduction To MATLAB This lecture is an introduction of the basic MATLAB commands. We learn; Functions Procedures for naming and saving the user generated files

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

Part V Appendices c Copyright, Todd Young and Martin Mohlenkamp, Department of Mathematics, Ohio University, 2017

Part V Appendices c Copyright, Todd Young and Martin Mohlenkamp, Department of Mathematics, Ohio University, 2017 Part V Appendices c Copyright, Todd Young and Martin Mohlenkamp, Department of Mathematics, Ohio University, 2017 Appendix A Glossary of Matlab Commands Mathematical Operations + Addition. Type help plus

More information

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

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix. MATLAB Tutorial 1 1 Department of Mathematics and Statistics, The University of New Mexico, Albuquerque, NM 87131 August 28, 2016 Contents: 1. Scalars, Vectors, Matrices... 1 2. Built-in variables, functions,

More information

Math Scientific Computing - Matlab Intro and Exercises: Spring 2003

Math Scientific Computing - Matlab Intro and Exercises: Spring 2003 Math 64 - Scientific Computing - Matlab Intro and Exercises: Spring 2003 Professor: L.G. de Pillis Time: TTh :5pm 2:30pm Location: Olin B43 February 3, 2003 Matlab Introduction On the Linux workstations,

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

MATLAB SUMMARY FOR MATH2070/2970

MATLAB SUMMARY FOR MATH2070/2970 MATLAB SUMMARY FOR MATH2070/2970 DUNCAN SUTHERLAND 1. Introduction The following is inted as a guide containing all relevant Matlab commands and concepts for MATH2070 and 2970. All code fragments should

More information

Chapter 1 MATLAB Preliminaries

Chapter 1 MATLAB Preliminaries Chapter 1 MATLAB Preliminaries 1.1 INTRODUCTION MATLAB (Matrix Laboratory) is a high-level technical computing environment developed by The Mathworks, Inc. for mathematical, scientific, and engineering

More information

Introduction to MATLAB

Introduction to MATLAB to MATLAB Spring 2019 to MATLAB Spring 2019 1 / 39 The Basics What is MATLAB? MATLAB Short for Matrix Laboratory matrix data structures are at the heart of programming in MATLAB We will consider arrays

More information

Programming in Mathematics. Mili I. Shah

Programming in Mathematics. Mili I. Shah Programming in Mathematics Mili I. Shah Starting Matlab Go to http://www.loyola.edu/moresoftware/ and login with your Loyola name and password... Matlab has eight main windows: Command Window Figure Window

More information

Programming 1. Script files. help cd Example:

Programming 1. Script files. help cd Example: Programming Until now we worked with Matlab interactively, executing simple statements line by line, often reentering the same sequences of commands. Alternatively, we can store the Matlab input commands

More information

Introduction to Engineering gii

Introduction to Engineering gii 25.108 Introduction to Engineering gii Dr. Jay Weitzen Lecture Notes I: Introduction to Matlab from Gilat Book MATLAB - Lecture # 1 Starting with MATLAB / Chapter 1 Topics Covered: 1. Introduction. 2.

More information

To start using Matlab, you only need be concerned with the command window for now.

To start using Matlab, you only need be concerned with the command window for now. Getting Started Current folder window Atop the current folder window, you can see the address field which tells you where you are currently located. In programming, think of it as your current directory,

More information

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example:

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example: Using MATLAB for Stochastic Simulation. Eric W. Hansen. Matlab Basics Introduction MATLAB (MATrix LABoratory) is a software package designed for efficient, reliable numerical computing. Using MATLAB greatly

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

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

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

A Short Introduction to Matlab

A Short Introduction to Matlab A Short Introduction to Matlab Sheng Xu & Daniel Reynolds SMU Mathematics, 2015 1 What is Matlab? Matlab is a computer language with many ready-to-use powerful and reliable algorithms for doing numerical

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

Matlab and Octave: Quick Introduction and Examples 1 Basics

Matlab and Octave: Quick Introduction and Examples 1 Basics Matlab and Octave: Quick Introduction and Examples 1 Basics 1.1 Syntax and m-files There is a shell where commands can be written in. All commands must either be built-in commands, functions, names of

More information

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

Interactive Computing with Matlab. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University Interactive Computing with Matlab Gerald W. Recktenwald Department of Mechanical Engineering Portland State University gerry@me.pdx.edu Starting Matlab Double click on the Matlab icon, or on unix systems

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

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

Some elements for Matlab programming

Some elements for Matlab programming Some elements for Matlab programming Nathalie Thomas 2018 2019 Matlab, which stands for the abbreviation of MATrix LABoratory, is one of the most popular language for scientic computation. The classical

More information

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003 Introduction to MATLAB Computational Probability and Statistics CIS 2033 Section 003 About MATLAB MATLAB (MATrix LABoratory) is a high level language made for: Numerical Computation (Technical computing)

More information

Basic MATLAB Tutorial

Basic MATLAB Tutorial Basic MATLAB Tutorial http://www1gantepedutr/~bingul/ep375 http://wwwmathworkscom/products/matlab This is a basic tutorial for the Matlab program which is a high-performance language for technical computing

More information

Entering the numbers in these two ways creates the same matrix A.

Entering the numbers in these two ways creates the same matrix A. Entering Matrices Entering the numbers in these two ways creates the same matrix A. EDU>> A = [ 2 3; 4 5 6; 7 8 9] A = 2 3 4 5 6 7 8 9 EDU>> A = [ 2 3 4 5 6 7 8 9 ] A = 2 3 4 5 6 7 8 9 Entering complex

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

How to Use MATLAB. What is MATLAB. Getting Started. Online Help. General Purpose Commands

How to Use MATLAB. What is MATLAB. Getting Started. Online Help. General Purpose Commands How to Use MATLAB What is MATLAB MATLAB is an interactive package for numerical analysis, matrix computation, control system design and linear system analysis and design. On the server bass, MATLAB version

More information

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Intro to matlab getting started Basic operations and a few illustrations This set is indepent from rest of the class notes. Matlab will be covered

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

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

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

A = [1, 6; 78, 9] Note: everything is case-sensitive, so a and A are different. One enters the above matrix as

A = [1, 6; 78, 9] Note: everything is case-sensitive, so a and A are different. One enters the above matrix as 1 Matlab Primer The purpose of these notes is a step-by-step guide to solving simple optimization and root-finding problems in Matlab To begin, the basic object in Matlab is an array; in two dimensions,

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

A QUICK INTRODUCTION TO MATLAB

A QUICK INTRODUCTION TO MATLAB A QUICK INTRODUCTION TO MATLAB Very brief intro to matlab Basic operations and a few illustrations This set is independent from rest of the class notes. Matlab will be covered in recitations and occasionally

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

MATH 3511 Basics of MATLAB

MATH 3511 Basics of MATLAB MATH 3511 Basics of MATLAB Dmitriy Leykekhman Spring 2012 Topics Sources. Entering Matrices. Basic Operations with Matrices. Build in Matrices. Build in Scalar and Matrix Functions. if, while, for m-files

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

Lecture 2: Variables, Vectors and Matrices in MATLAB

Lecture 2: Variables, Vectors and Matrices in MATLAB Lecture 2: Variables, Vectors and Matrices in MATLAB Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1 and Chapter 2. Variables

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

MatLab Just a beginning

MatLab Just a beginning MatLab Just a beginning P.Kanungo Dept. of E & TC, C.V. Raman College of Engineering, Bhubaneswar Introduction MATLAB is a high-performance language for technical computing. MATLAB is an acronym for MATrix

More information

AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA

AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA MATLAB (short for MATrix LABoratory) is a very useful piece of software for numerical

More information

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to.

Starting Matlab. MATLAB Laboratory 09/09/10 Lecture. Command Window. Drives/Directories. Go to. Starting Matlab Go to MATLAB Laboratory 09/09/10 Lecture Lisa A. Oberbroeckling Loyola University Maryland loberbroeckling@loyola.edu http://ctx.loyola.edu and login with your Loyola name and password...

More information

AMS 27L LAB #2 Winter 2009

AMS 27L LAB #2 Winter 2009 AMS 27L LAB #2 Winter 2009 Plots and Matrix Algebra in MATLAB Objectives: 1. To practice basic display methods 2. To learn how to program loops 3. To learn how to write m-files 1 Vectors Matlab handles

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

EP375 Computational Physics

EP375 Computational Physics EP375 Computational Physics Topic 1 MATLAB TUTORIAL BASICS Department of Engineering Physics University of Gaziantep Feb 2014 Sayfa 1 Basic Commands help command get help for a command clear all clears

More information

LabVIEW MathScript Quick Reference

LabVIEW MathScript Quick Reference Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics LabVIEW MathScript Quick Reference Hans-Petter Halvorsen, 2012.06.14 Faculty of Technology, Postboks

More information

Getting Started with MATLAB

Getting Started with MATLAB APPENDIX B Getting Started with MATLAB MATLAB software is a computer program that provides the user with a convenient environment for many types of calculations in particular, those that are related to

More information

Introduction to MATLAB

Introduction to MATLAB 58:110 Computer-Aided Engineering Spring 2005 Introduction to MATLAB Department of Mechanical and industrial engineering January 2005 Topics Introduction Running MATLAB and MATLAB Environment Getting help

More information

ENGR 253 LAB #1 - MATLAB Introduction

ENGR 253 LAB #1 - MATLAB Introduction ENGR 253 LAB #1 - MATLAB Introduction Objective Understanding and hands on experience with MATLAB with focus on Signal Processing. Resources Signals & Systems textbook by Oppenheim and Willsky Windows

More information

CME 192: Introduction to Matlab

CME 192: Introduction to Matlab CME 192: Introduction to Matlab Matlab Basics Brett Naul January 15, 2015 Recap Using the command window interactively Variables: Assignment, Identifier rules, Workspace, command who and whos Setting the

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Contents 1.1 Objectives... 1 1.2 Lab Requirement... 1 1.3 Background of MATLAB... 1 1.4 The MATLAB System... 1 1.5 Start of MATLAB... 3 1.6 Working Modes of MATLAB... 4 1.7 Basic

More information

Matlab Programming Introduction 1 2

Matlab Programming Introduction 1 2 Matlab Programming Introduction 1 2 Mili I. Shah August 10, 2009 1 Matlab, An Introduction with Applications, 2 nd ed. by Amos Gilat 2 Matlab Guide, 2 nd ed. by D. J. Higham and N. J. Higham Starting Matlab

More information

MATH 5520 Basics of MATLAB

MATH 5520 Basics of MATLAB MATH 5520 Basics of MATLAB Dmitriy Leykekhman Spring 2011 Topics Sources. Entering Matrices. Basic Operations with Matrices. Build in Matrices. Build in Scalar and Matrix Functions. if, while, for m-files

More information

MATLAB GUIDE UMD PHYS401 SPRING 2012

MATLAB GUIDE UMD PHYS401 SPRING 2012 MATLAB GUIDE UMD PHYS40 SPRING 202 We will be using Matlab (or, equivalently, the free clone GNU/Octave) this semester to perform calculations involving matrices and vectors. This guide gives a brief introduction

More information

1 Week 1: Basics of scientific programming I

1 Week 1: Basics of scientific programming I MTH739N/P/U: Topics in Scientific Computing Autumn 2016 1 Week 1: Basics of scientific programming I 1.1 Introduction The aim of this course is use computing software platforms to solve scientific and

More information

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks MATLAB Basics Stanley Liang, PhD York University Configure a MATLAB Package Get a MATLAB Student License on Matworks Visit MathWorks at https://www.mathworks.com/ It is recommended signing up with a student

More information

Consider this m file that creates a file that you can load data into called rain.txt

Consider this m file that creates a file that you can load data into called rain.txt SAVING AND IMPORTING DATA FROM A DATA FILES AND PROCESSING AS A ONE DIMENSIONAL ARRAY If we save data in a file sequentially than we can call it back sequentially into a row vector. Consider this m file

More information

(Creating Arrays & Matrices) Applied Linear Algebra in Geoscience Using MATLAB

(Creating Arrays & Matrices) Applied Linear Algebra in Geoscience Using MATLAB Applied Linear Algebra in Geoscience Using MATLAB (Creating Arrays & Matrices) Contents Getting Started Creating Arrays Mathematical Operations with Arrays Using Script Files and Managing Data Two-Dimensional

More information

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

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB? Appendix A Introduction to MATLAB A.1 What Is MATLAB? MATLAB is a technical computing environment developed by The Math- Works, Inc. for computation and data visualization. It is both an interactive system

More information

Computational Foundations of Cognitive Science. Inverse. Inverse. Inverse Determinant

Computational Foundations of Cognitive Science. Inverse. Inverse. Inverse Determinant Computational Foundations of Cognitive Science Lecture 14: s and in Matlab; Plotting and Graphics Frank Keller School of Informatics University of Edinburgh keller@inf.ed.ac.uk February 23, 21 1 2 3 Reading:

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

QUICK INTRODUCTION TO MATLAB PART I

QUICK INTRODUCTION TO MATLAB PART I QUICK INTRODUCTION TO MATLAB PART I Department of Mathematics University of Colorado at Colorado Springs General Remarks This worksheet is designed for use with MATLAB version 6.5 or later. Once you have

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab November 22, 2013 Contents 1 Introduction to Matlab 1 1.1 What is Matlab.................................. 1 1.2 Matlab versus Maple............................... 2 1.3 Getting

More information

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY What is MATLAB? MATLAB (MATrix LABoratory) developed by The Mathworks, Inc. (http://www.mathworks.com) Key Features: High-level language for numerical

More information

CSE/NEUBEH 528 Homework 0: Introduction to Matlab

CSE/NEUBEH 528 Homework 0: Introduction to Matlab CSE/NEUBEH 528 Homework 0: Introduction to Matlab (Practice only: Do not turn in) Okay, let s begin! Open Matlab by double-clicking the Matlab icon (on MS Windows systems) or typing matlab at the prompt

More information

A General Introduction to Matlab

A General Introduction to Matlab Master Degree Course in ELECTRONICS ENGINEERING http://www.dii.unimore.it/~lbiagiotti/systemscontroltheory.html A General Introduction to Matlab e-mail: luigi.biagiotti@unimore.it http://www.dii.unimore.it/~lbiagiotti

More information

Digital Image Analysis and Processing CPE

Digital Image Analysis and Processing CPE Digital Image Analysis and Processing CPE 0907544 Matlab Tutorial Dr. Iyad Jafar Outline Matlab Environment Matlab as Calculator Common Mathematical Functions Defining Vectors and Arrays Addressing Vectors

More information

Quick MATLAB Syntax Guide

Quick MATLAB Syntax Guide Quick MATLAB Syntax Guide Some useful things, not everything if-statement Structure: if (a = = = ~=

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

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

Getting started with MATLAB

Getting started with MATLAB Sapienza University of Rome Department of economics and law Advanced Monetary Theory and Policy EPOS 2013/14 Getting started with MATLAB Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Outline

More information

An Introduction to Numerical Methods

An Introduction to Numerical Methods An Introduction to Numerical Methods Using MATLAB Khyruddin Akbar Ansari, Ph.D., P.E. Bonni Dichone, Ph.D. SDC P U B L I C AT I O N S Better Textbooks. Lower Prices. www.sdcpublications.com Powered by

More information

ARRAY VARIABLES (ROW VECTORS)

ARRAY VARIABLES (ROW VECTORS) 11 ARRAY VARIABLES (ROW VECTORS) % Variables in addition to being singular valued can be set up as AN ARRAY of numbers. If we have an array variable as a row of numbers we call it a ROW VECTOR. You can

More information

An Introductory Guide to MATLAB

An Introductory Guide to MATLAB CPSC 303 An Introductory Guide to MATLAB Ian Cavers Department of Computer Science University of British Columbia 99W T2 1 Introduction MATLAB provides a powerful interactive computing environment for

More information

A quick Matlab tutorial

A quick Matlab tutorial A quick Matlab tutorial Michael Robinson 1 Introduction In this course, we will be using MATLAB for computer-based matrix computations. MATLAB is a programming language/environment that provides easy access

More information

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS 1 6 3 Matlab 3.1 Fundamentals Matlab. The name Matlab stands for matrix laboratory. Main principle. Matlab works with rectangular

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

Introduction to MATLAB 7 for Engineers PowerPoint to accompany Introduction to MATLAB 7 for Engineers William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2005. The McGraw-Hill Companies, Inc. Permission required for

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced

More information

Introduction to MATLAB for Engineers, Third Edition

Introduction to MATLAB for Engineers, Third Edition PowerPoint to accompany Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2010. The McGraw-Hill Companies, Inc. This work is

More information

MATLAB. A Tutorial By. Masood Ejaz

MATLAB. A Tutorial By. Masood Ejaz MATLAB A Tutorial By Masood Ejaz Note: This tutorial is a work in progress and written specially for CET 3464 Software Programming in Engineering Technology, a course offered as part of BSECET program

More information