Introduction to MATLAB
|
|
- Hugh Rich
- 6 years ago
- Views:
Transcription
1 Sven K. Esche Department of Mechanical Engineering January,
2 Learning Objectives Using MATLAB, the student will be able to perform the following: Run MATLAB Manage MATLAB workspace Use MATLAB Editor to create m-files Input/output data from/to files Define constants, variables, vectors and matrices Perform simple calculations using numbers, vectors, matrices, operators and functions January, Sven K. Esche
3 Learning Objectives (cont.) Solve systems of linear equations Solve eigenvalue problems Generate D and 3D plots Solve systems of linear and nonlinear ODEs Solve unconstrained optimization problems Perform numerical integration Develop animations January, Sven K. Esche 3
4 MATLAB Background MATLAB (MATrix LABoratory) is highperformance language for technical computing MATLAB integrates computation, visualization, and programming in an easy-to-use environment Problems and solutions are expressed in familiar mathematical notation Basic data element is an array that does not require dimensioning demo MATLAB demonstration program January, Sven K. Esche 4
5 MATLAB Environment Prompt: (>>) indicates that MATLAB is ready to accept commands clc clears the Command Window % indicates a comment When a line ends with a semicolon (;), MATLAB performs the computation but does not display any output Three periods (...) followed by Return or Enter indicate that the statement continues on the next line format short/long/short e/long e formatting January, Sven K. Esche 5
6 MATLAB Workspace Command whos displays the name, size, and data type information for all variables defined in the workspace Command clear deletes all existing variables from the workspace January, Sven K. Esche 6
7 Computer Limits Command [ctype, maxsize] = computer displays type of computer ctype and max. array size maxsize Command intmax displays largest integer value Commands realmin /realmax display smallest / largest positive floating point number representable on the computer Command eps floating point accuracy January, Sven K. Esche 7
8 Example: Environment Perform the following operations: Clear workspace and command window Switch on echo function Evaluate expression - / + /3 - /4 + /5 - /6 + /7 - /8 + /9 - / + / - / using line continuation Suppress output when evaluating expression - / + /3 - /4 + /5 - /6 + /7; January, Sven K. Esche 8
9 Example: Environment (cont.) List name, size and data type of all variables in workspace Display current search path and current directory List all MATLAB files and all files in current directory January, Sven K. Esche 9
10 MATLAB Search Path When the name test is entered at the MATLAB prompt, the MATLAB interpreter Looks for test as a variable Checks for test as a built-in function Looks in the current directory for a file named test.m Searches the directories on the search path for test.m January, Sven K. Esche
11 MATLAB Search Path (cont.) Command path displays the current search path Command addpath /home/me64 appends the directory /home/me64 to the current path Command rmpath /home/me64 removes the directory /home/me64 from the current path Command pathtool starts the interactive Path Browser January, Sven K. Esche
12 MATLAB Search Path (cont.) Command cd (without any arguments) displays the current directory Command cd with a path changes the current directory Command what lists all MATLAB files in the current directory The exclamation point (!) is a shell escape (the rest of the input line is a command to the operating system) January, Sven K. Esche
13 M-Files Command type data.m displays existing m-file data.m Command edit launches the MATLAB Editor/Debugger with empty m-file Command edit data.m launches the MATLAB Editor/Debugger with existing m-file data.m Command dir lists all files in the current directory January, Sven K. Esche 3
14 Data Input / Output inputvar = input( input prompt ) displays string input prompt, waits for value to be entered from keyboard and assigns it to variable inputvar isempty(a) returns if array A is empty and otherwise save( filename, var, var, -ascii) save data in var and var to ASCII file inputvar = textread( filename', '%f') read floating point value from file January, Sven K. Esche 4
15 Program Flow Control if, else, elseif execution of statements if certain expression is TRUE switch, case, otherwise execution of statements depending on value of expressions for, while, continue, break loop for repeated execution of statements try, catch error control return program termination January, Sven K. Esche 5
16 MATLAB Expressions Building blocks of MATLAB expressions are: Constants Variables Operators Functions January, Sven K. Esche 6
17 MATLAB Data Types Scalars Vectors Matrices Strings Special values January, Sven K. Esche 7
18 Numbers Conventional decimal notation: optional decimal point and plus or minus sign Scientific notation: e to denote power-often factor Complex numbers: imaginary unit i or j Numbers are internally stored using long format specified by IEEE floating-point standard Special constants: pi, Inf, NaN January, Sven K. Esche 8
19 Variables MATLAB does not require type declarations and definition of dimensions (automatic variable creation and memory allocation) Variable names start with letter followed by letters, numbers and underscores (no punctuation characters) case sensitive 3 significant characters January, Sven K. Esche 9
20 Operators Arithmetic operators: +, -,.*,./,.\,.^ Relational operators: <, <=, >, >=, ==, ~= Logical operators: AND (&), OR ( ), NOT (~) Special operators: %,,., :, ; January, Sven K. Esche
21 Arithmetic Operators + Addition - Subtraction * Multiplication / Division \ Left division (described later) ^ Power ( ) Specification of evaluation order January, Sven K. Esche
22 Relational Operators < less than <= less than or equal than > greater than >= greater than or equal than == equal to ~= not equal to January, Sven K. Esche
23 Logical Operators AND (&) TRUE if all inputs are TRUE OR ( ) TRUE if at least one input is TRUE NOT (~) TRUE if the input is FALSE January, Sven K. Esche 3
24 Special Operators % comment Complex conjugate transpose. elementwise execution of vector/matrix operations : creation of equally spaced vectors ; output suppression January, Sven K. Esche 4
25 MATLAB Commands <command>enter <variable> = <command>enter [<variables>] = <command>enter January, Sven K. Esche 5
26 Example: Numbers Perform the following operations: Define integer numbers 3 and -99 Define real numbers., ,.6 -, Define complex numbers +i, j and 3 5 i Define Explore expressions / and / Define variables my_favorite_number = 3 and x = January, Sven K. Esche 6
27 Mathematical Functions sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan(x, y) trigonometric functions sinh(x), cosh(x), tanh(x), asinh(x), acosh(x), atanh(x) hyperbolic functions exp(x), a^x, log(x), log(x) exponential and logarithmic functions January, Sven K. Esche 7
28 Mathematical Functions (cont.) abs(z), angle(z), conj(z), imag(z), real(z) complex functions abs(x) absolute value sign(x) signum sqrt(x) square root January, Sven K. Esche 8
29 Example: Functions Evaluate the following functions: sin(), cos(), tan(), sin - (.5), cos - (.5), tan - (.5), tan - (.5/) sinh(), cosh(), tanh(), sinh - (.5), cosh - (.5), tanh - (.5) e.5,.5, ln.5, log.5 +i, arg(+i), Re(+j), Im(+j), -.5, sign(-.5),.5 i January, Sven K. Esche 9
30 Simple Calculations Type commands directly at prompt Generate m-file using MATLAB Editor/Debugger (command edit, select Save As from Editor/Debugger File menu, select Run Script from MATLAB Command Window File menu) Calculator approach: +3 Variable approach: a=; b=3; a+b January, Sven K. Esche 3
31 Matrices Rectangular arrangement of numbers Special matrices: -by- matrix (scalar) -by-n or n-by- matrices (vectors) Defining a matrix in MATLAB: Enter an explicit list of elements Load matrices from external data files Generate matrices using built-in functions Create matrices with your own functions in M-files January, Sven K. Esche 3
32 Special Matrices zeros(m,n) generates m-by-n matrix of zeroes ones(m,n) generates m-by-n matrix of ones rand(m,n) generates m-by-n matrix of random numbers that are uniformly distributed in the interval (,) eye(n) generates n-by-n identity matrix January, Sven K. Esche 3
33 Basic Matrix Operations A (complex conjugate) transpose of A fliplr(a) flip A left to right size(a) size (dimensions) of A sum(a) sum of elements of each column of A diag(a) main diagonal of A trace(a) sum of diagonal elements (trace) of A January, Sven K. Esche 33
34 Advanced Matrix Operations det(a) determinant of matrix A rank(a) rank of matrix A rref(a) reduced row echelon form of A cond(a) condition number of matrix A inv(a) inverse of matrix A lu(a) LU factorization of matrix A qr(a) QR factorization of matrix A orth(a) orthonormal basis for range of A January, Sven K. Esche 34
35 Matrix Subscripts A(i, j) element in i th row and j th column A(i, :), A(:, j) i th row and j th column Reference to element outside of range leads to error message Index exceeds matrix dimensions. Upon storing a value in element outside of range, matrix size is automatically increased January, Sven K. Esche 35
36 Generation of Vectors i:j generates row vector containing integers from i to j with unit spacing i:j:k generates row vector containing integers from i to k with spacing of j a:b:c generates row vector containing real numbers from a to c with spacing of b linspace(a, b, n) generates row vector containing n real numbers from a to b January, Sven K. Esche 36
37 January, Sven K. Esche 37 Introduction to MATLAB Perform the following operations: Define matrices A, B, C, D and E E rand rand rand rand rand rand D C B A Example: Matrices
38 Example: Matrices (cont.) Determine the following A T dimensions of det A A condition number of A sum of columns of A main diagonal of A Refer to element A(, 3) Assign value to element A(, 4) January, Sven K. Esche 38
39 Example: Matrices (cont.) Define row and column vectors a, b, c, d and e: a b c d e T January, Sven K. Esche 39
40 Solving Systems of Equations Solution of system of linear equations A * x = b If b is zero vector, either det(a) is zero or x is zero vector x = null(a) solution of A * x = If b is nonzero, det(a) must be nonzero x = A \ b (more accurate and faster) x = inv(a) * b (less accurate and slower) January, Sven K. Esche 4
41 January, Sven K. Esche 4 Introduction to MATLAB Example: Singular System Given: Coefficient matrix A Right-hand-side vector b Note: A T b
42 Example: Singular System (cont.) Find: Determinant and condition number of A Inverse of A Check accuracy of inverse Solve system of equations A x = b using inverse of A Check solution accuracy Solve system of equations A x = b using backslash operator Check solution accuracy January, Sven K. Esche 4
43 Example: Singular System (cont.) Solution: Determinant of A: det A Condition number of A: cond 6 A 3.83 Inverse of A: A January, Sven K. Esche 43
44 January, Sven K. Esche 44 Introduction to MATLAB Example: Singular System (cont.) Check accuracy of inverse of A: Solve system of equations A x = b using inverse of A T T b A x A A AA
45 Example: Singular System (cont.) Check solution accuracy Ax b Solve system of equations A x = b using backslash operator x T T A \ b 7 Check solution accuracy Ax b T 3 T T T January, Sven K. Esche 45
46 Solving Eigenvalue Problems Solve eigenvalue problem A * v = * v [V, ] = eig(a) Matrix V containing eigenvectors v i as columns Matrix containing eigenvalues i on main diagonal poly(a) returns row vector with coefficients of characteristic polynomial of A in order of descending powers January, Sven K. Esche 46
47 Example: Eigenvalue Problem Given: Matrix A: Find: A Eigenvalues and eigenvectors using eig function Check solution accuracy Coefficients of characteristic polynomial Roots of characteristic polynomial Eigenvectors using null function 5 8 January, Sven K. Esche 47
48 Example: Eigenvalue Problem (cont.) Solution: Eigenvalues using eig function: Eigenvectors using eig function: v V v v January, Sven K. Esche 48
49 Example: Eigenvalue Problem (cont.) Check solution accuracy: 4 Av v T Av v Av3 3v T.53 4 A Iv T A Iv A Iv T 3 3 T T January, Sven K. Esche 49
50 Example: Eigenvalue Problem (cont.) Coefficients of characteristic polynomial 3 p(): p Roots i of characteristic polynomial p(): Eigenvectors using null function: v V v v January, Sven K. Esche
51 -D Plotting Functions plot(x, y) plot -D lines (graphs) feather(u, v) plot vectors with components (u, v) emanating from equally spaced points along a horizontal axis quiver(x, y, u, v) plot vectors as arrows with components (u, v) at points (x, y) contour(x, y, z) plot contour lines of surface z = f(x, y) = const. January, Sven K. Esche 5
52 3-D Plotting Functions plot3(x, y, z) plot 3-D lines (graphs) surf(x, y, z) plot shaded surface z = f(x, y) mesh(x, y, z) plot wireframe mesh of surface z = f(x, y) quiver3(x, y, z, u, v, w) plot vectors with components (u, v, w) at points (x, y, z) January, Sven K. Esche 5
53 Plot Options title( text ) put title text above plot xlabel( text ), ylabel( text ), zlabel( text ) put label text on x-, y- or z-axis legend( text ) put legend on graphs grid put grid on plot axis( equal ) ensure uniform scaling of x-axis and y-axis axis([xmin xmax ymin ymax]) specify plotting range for x-axis and y-axis January, Sven K. Esche 53
54 Plot Options (cont.) linespec set line style, width, color, marker type, marker size -, - -, :, -: solid, dashed, dotted, dash-dot line linewidth n set line width of graphs to n dots r, g, b, c, m, y, k, w red, green, blue, cyan, magenta, yellow, black, white line color January, Sven K. Esche 54
55 Plot Options (cont.) +, o, *,., x plus, circle, asterisk, dot, cross marker hold on/off add to/overwrite current graph zoom on/off zoom in/out interactively view(az, el) set azimuth and elevation viewing angle of plot figure create another figure window January, Sven K. Esche 55
56 Exporting Graphics Files Generate graphic using plot command Select Export from Figure Window File menu Select file name and file type (*.tif, *.jpeg, etc.) from Export Window January, Sven K. Esche 56
57 Example: Plotting a Graph Given: Function z(t): z f t x t y t t x t e y t sin t Find: Plot graphs of x(t), y(t) and z(t) in interval [, ] Add title, axis labels, legend and grid to figure Export figure as jpg file January, Sven K. Esche 57
58 Example: Plotting a Graph (cont.) Solution: January, Sven K. Esche 58
59 Example: Surface Plot Given: Function z: Find: Surface plot Mesh plot Contour plot z f 3 3 x, y.5x 6xy 4y January, Sven K. Esche 59
60 Example: Surface Plot (cont.) Solution: Surface plot January, Sven K. Esche 6
61 Example: Surface Plot (cont.) Mesh plot January, Sven K. Esche 6
62 Example: Surface Plot (cont.) Contour plot January, Sven K. Esche 6
63 Solving Linear ODEs ode45 Numerical solution of ordinary differential equation y = f(t, y) [t, y] = ode45( filename, t, y) t row vector with discrete time values y matrix with solutions for y and y in first and second columns filename name of m-file containing y = f(t, y) y row vector with initial conditions y() and y () in first and second columns January, Sven K. Esche 63
64 Example: Van der Pol s ODE Given: Van der Pol s differential equation: d x/dt -m ( -x ) dx/dt + x = Initial conditions: x() =, dx/dt() = Find: Numerical solution using ode45 function Time plot and phase plane plot January, Sven K. Esche 64
65 January, Sven K. Esche 65 Introduction to MATLAB Example: Van der Pol s ODE (cont.) Solution: Convert nd order ODE into system of two st order ODEs Define time vector t and initial condition vector y y y y m y x x y y x x y y x x x m x dt x d x dt dx x x dt dx x m dt x d y y T T o o, x, x y
66 Example: Van der Pol s ODE (cont.) Results: January, Sven K. Esche 66
67 Example: Double Pendulum Given: Spring-loaded double pendulum System parameters m = m =. kg d =.5 m, l =.5 m k = k 3 = N/m, k = N/m Initial conditions () =. rad, () =. rad = =. rad/s January, Sven K. Esche 67
68 Example: Double Pendulum (cont.) Find: Numerical solution using ode45 function Time plot Solution: Governing equations (for small angles): m l m l k k d mgl k d k k d m gl k d 3 January, Sven K. Esche 68
69 January, Sven K. Esche 69 Introduction to MATLAB Example: Double Pendulum (cont.) Convert ODEs T m l y m gl d k k y d k y m l y m gl d k k y d k y y y y y y y y y y y y
70 Example: Double Pendulum (cont.) Results: January, Sven K. Esche 7
71 Unconstrained Minimization Define (column) residue vector R = f(x) Define (scalar) objective function F(x) = R(x) T R(x) Minimize objective function using [x, fval] = fminsearch( filename, x, options) filename name of m-file containing F(x) x row vector with initial guess for x January, Sven K. Esche 7
72 Unconstrained Minimization (cont.) Options Display off, iter, final level of output display during iteration TolX termination tolerance for x TolFun termination tolerance for F(x) MaxIter maximum number of iterations allowed MaxFunEvals maximum number of function evaluations allowed January, Sven K. Esche 7
73 Example: Banana Function Given: Rosenbrock's banana function (objective function: f f x f x, y x y x T x R x R x x y x Initial vector: x T T x y. Find: x y x Surface and contour plots of f(x, y) Local minimum using fminsearch function January, Sven K. Esche 73
74 Example: Banana Function Solution: Result (minimum): f * * y * x x x * * * T x y T * x January, Sven K. Esche 74
75 Example: Four-bar Linkage Given: Link lengths: l = 3 in, l = in, l 3 = 4 in, l 4 = 3.5 in Link orientations: = º, = 45º Find: Assembled configuration Animation for full crank rotation January, Sven K. Esche 75
76 Example: Four-bar Linkage (cont.) Solution: Define residue vector R = f(x i, y i, i ) x i : x-coordinates of link centers of gravity y i : y-coordinates of link centers of gravity i : link orientations Define (scalar) objective function F = R(x i, y i, i ) T R(x i, y i, i ) Minimize objective function using fminsearch( filename, x, options) January, Sven K. Esche 76
77 Example: Four-bar Linkage (cont.) Initial and final configurations: January, Sven K. Esche 77
78 Numerical Integration Using quad quad( filename, a, b, tol) evaluate definite integral using adaptive Simpson quadrature filename name of m-file containing function f(x) to be integrated a, b finite integration limits tol absolute error tolerance January, Sven K. Esche 78
79 Example: Quadrature Given: Function f(x) = sin(x) Find: Euclidean norm of f(x) on interval [, ] Solution: Analytical solution: f f b x f x,f x f x dx sin x x sin x 4 x. 775 January, Sven K. Esche 79 a dx
80 Example: Quadrature (cont.) Main program: nsin = quad( matlab_quad_sub',, ( * pi)); nsin = sqrt(nsin) Subroutine: function nsin = matlab_quad_sub(x); nsin = sin(x).^ ; Numerical result: sin(x) =.775 January, Sven K. Esche 8
81 Numerical Integration Using trapz trapz(x, y) evaluate definite integral using trapezoidal numerical integration x (uniformly or nonuniformly spaced) integration grid (row vector) y function values y i = f(x i ) January, Sven K. Esche 8
82 Example: Trapezoidal Rule Given: Function f(x) = sin(x) Find: Definite integral of f(x) on interval [, ] Solution: Analytical solution: sin xdx cos x January, Sven K. Esche 8
83 Example: Trapezoidal Rule (cont.) MATLAB program: x =.:pi/8.:pi; y = sin(x); trapz(x, y) Numerical result: sin xdx.9999 January, Sven K. Esche 83
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 informationWhat 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 informationMATLAB 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 informationInlichtingenblad, 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 informationMATLAB 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 informationIntroduction 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 informationPART 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 informationPart 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 informationAMS 27L LAB #1 Winter 2009
AMS 27L LAB #1 Winter 2009 Introduction to MATLAB Objectives: 1. To introduce the use of the MATLAB software package 2. To learn elementary mathematics in MATLAB Getting Started: Log onto your machine
More informationIntroduction 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 informationIntroduction 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 informationFundamentals of MATLAB Usage
수치해석기초 Fundamentals of MATLAB Usage 2008. 9 담당교수 : 주한규 joohan@snu.ac.kr, x9241, Rm 32-205 205 원자핵공학과 1 MATLAB Features MATLAB: Matrix Laboratory Process everything based on Matrix (array of numbers) Math
More informationA 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 informationIntroduction 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 informationLecturer: Keyvan Dehmamy
MATLAB Tutorial Lecturer: Keyvan Dehmamy 1 Topics Introduction Running MATLAB and MATLAB Environment Getting help Variables Vectors, Matrices, and linear Algebra Mathematical Functions and Applications
More informationIntroduction 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 informationProf. 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 informationMATLAB 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 informationProgramming 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 informationIntroduction 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 information1 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 informationMATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)
Digital Signal Processing Prof. Nizamettin AYDIN naydin@yildiz.edu.tr naydin@ieee.org http://www.yildiz.edu.tr/~naydin Course Details Course Code : 0113620 Course Name: Digital Signal Processing (Sayısal
More informationDigital 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 informationMATLAB 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 informationMATLAB 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 informationMATLAB Lecture 1. Introduction to MATLAB
MATLAB Lecture 1. Introduction to MATLAB 1.1 The MATLAB environment MATLAB is a software program that allows you to compute interactively with matrices. If you want to know for instance the product of
More informationIntroduction 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 informationScientific Computing Lecture 1: MATLAB fundamentals
Scientific Computing Lecture 1: MATLAB fundamentals InFoMM CDT Mathematical Institute University of Oxford Andrew Thompson (slides by Stuart Murray) Lecture I: MATLAB fundamentals What is MATLAB? MATLAB
More informationIntroduction 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 informationMatlab Tutorial, CDS
29 September 2006 Arrays Built-in variables Outline Operations Linear algebra Polynomials Scripts and data management Help: command window Elisa (see Franco next slide), Matlab Tutorial, i.e. >> CDS110-101
More informationLecture 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 informationMATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED. Christian Daude 1
MATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED Christian Daude 1 Introduction MATLAB is a software package designed to handle a broad range of mathematical needs one may encounter when doing scientific
More informationLogical 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 informationIntroduction 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 informationIntroduction 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 informationIntroduction 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 informationMATLAB BEGINNER S GUIDE
MATLAB BEGINNER S GUIDE About MATLAB MATLAB is an interactive software which has been used recently in various areas of engineering and scientific applications. It is not a computer language in the normal
More informationIntroduction 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 informationLab 1 - Worksheet Spring 2013
Math 300 UMKC Lab 1 - Worksheet Spring 2013 Learning Objectives: 1. How to use Matlab as a calculator 2. Learn about Matlab built in functions 3. Matrix and Vector arithmetics 4. MATLAB rref command 5.
More informationLabVIEW 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 informationChapter 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 informationLAB 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 informationDr Richard Greenaway
SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 2 Basic MATLAB Operation Dr Richard Greenaway 2 Basic MATLAB Operation 2.1 Overview 2.1.1 The Command Line In this Workshop you will learn how
More informationGetting 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 informationInteractive 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 informationIntroduction to MATLAB
CHEE MATLAB Tutorial Introduction to MATLAB Introduction In this tutorial, you will learn how to enter matrices and perform some matrix operations using MATLAB. MATLAB is an interactive program for numerical
More informationConsider 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 informationWelcome to EGR 106 Foundations of Engineering II
Welcome to EGR 106 Foundations of Engineering II Course information Today s specific topics: Computation and algorithms MATLAB Basics Demonstrations Material in textbook chapter 1 Computation What is computation?
More informationIntroduction 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 informationA 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 informationIntroduction 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 informationMATLAB Premier. Middle East Technical University Department of Mechanical Engineering ME 304 1/50
MATLAB Premier Middle East Technical University Department of Mechanical Engineering ME 304 1/50 Outline Introduction Basic Features of MATLAB Prompt Level and Basic Arithmetic Operations Scalars, Vectors,
More informationIntroduction 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 informationStarting MATLAB To logon onto a Temple workstation at the Tech Center, follow the directions below.
What is MATLAB? MATLAB (short for MATrix LABoratory) is a language for technical computing, developed by The Mathworks, Inc. (A matrix is a rectangular array or table of usually numerical values.) MATLAB
More informationCDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation
CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted
More informationCDA5530: 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 information1.1 ABOUT MATLAB and MATLAB GUI (Graphical User Interface)
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.
More informationMATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations
MATLAB Tutorial The following tutorial has been compiled from several resources including the online Help menu of MATLAB. It contains a list of commands that will be directly helpful for understanding
More informationProgramming in MATLAB
trevor.spiteri@um.edu.mt http://staff.um.edu.mt/trevor.spiteri Department of Communications and Computer Engineering Faculty of Information and Communication Technology University of Malta 17 February,
More informationMATLAB 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 information2.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 informationComputer Programming in MATLAB
Computer Programming in MATLAB Prof. Dr. İrfan KAYMAZ Atatürk University Engineering Faculty Department of Mechanical Engineering What is a computer??? Computer is a device that computes, especially a
More information1 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 informationCDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation
CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted
More informationIdentity Matrix: >> eye(3) ans = Matrix of Ones: >> ones(2,3) ans =
Very Basic MATLAB Peter J. Olver January, 2009 Matrices: Type your matrix as follows: Use space or, to separate entries, and ; or return after each row. >> [;5 0-3 6;; - 5 ] or >> [,5,6,-9;5,0,-3,6;7,8,5,0;-,,5,]
More informationSome 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 informationAppendix 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 informationQuick MATLAB Syntax Guide
Quick MATLAB Syntax Guide Some useful things, not everything if-statement Structure: if (a = = = ~=
More informationTo 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 informationConstraint-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 informationTable of Contents. Basis CEMTool 7 Tutorial
PREFACE CEMTool (Computer-aided Engineering & Mathematics Tool) is a useful computational tool in science and engineering. No matter what you background be it physics, chemistry, math, or engineering it
More informationThis 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 informationExperiment 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 informationA 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 informationWhat is Matlab? The command line Variables Operators Functions
What is Matlab? The command line Variables Operators Functions Vectors Matrices Control Structures Programming in Matlab Graphics and Plotting A numerical computing environment Simple and effective programming
More informationIntroduction to Matlab
Introduction to Matlab What is Matlab The software program called Matlab (short for MATrix LABoratory) is arguably the world standard for engineering- mainly because of its ability to do very quick prototyping.
More informationMATLAB 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 informationMATLAB 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 informationOutline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.
CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
More information! 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 informationBasic 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 informationEng 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 informationIntroduction to MATLAB
Computational Photonics, Seminar 0 on Introduction into MATLAB, 3.04.08 Page Introduction to MATLAB Operations on scalar variables >> 6 6 Pay attention to the output in the command window >> b = b = >>
More informationOutline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An
CSE 170 Interacting with MATLAB Instructor: Aijun An Department of Computer Science and Engineering York University aan@cse.yorku.ca Outline Starting MATLAB MATLAB Windows Using the Command Window Some
More informationGetting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text
Chapter 1 Getting Started How to Get Matlab Matlab physically resides on each of the computers in the Olin Hall labs. See your instructor if you need an account on these machines. If you are going to go
More informationWhat 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 informationComputational 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 information12 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 informationUser manual. Version 9.2.0
User manual A B Version 9.2.0 Contents 1 Calculation 2 1.1 Using the application............................ 2 1.1.1 Doing a calculation......................... 2 1.1.2 Using the result of the immediately
More informationQUICK 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 informationSECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing
SECTION 1: INTRODUCTION ENGR 112 Introduction to Engineering Computing 2 Course Overview What is Programming? 3 Programming The implementation of algorithms in a particular computer programming language
More informationPROGRAMMING WITH MATLAB DR. AHMET AKBULUT
PROGRAMMING WITH MATLAB DR. AHMET AKBULUT OVERVIEW WEEK 1 What is MATLAB? A powerful software tool: Scientific and engineering computations Signal processing Data analysis and visualization Physical system
More informationIntroduction 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 informationStarting 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 informationOrdinary 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 informationMath Sciences Computing Center. University ofwashington. September, Fundamentals Making Plots Printing and Saving Graphs...
Introduction to Plotting with Matlab Math Sciences Computing Center University ofwashington September, 1996 Contents Fundamentals........................................... 1 Making Plots...........................................
More informationBasic 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 informationIntroduction 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 informationLaboratory 1 Octave Tutorial
Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory
More informationPart #1. A0B17MTB Matlab. Miloslav Čapek Filip Kozák, Viktor Adler, Pavel Valtr
A0B17MTB Matlab Part #1 Miloslav Čapek miloslav.capek@fel.cvut.cz Filip Kozák, Viktor Adler, Pavel Valtr Department of Electromagnetic Field B2-626, Prague You will learn Scalars, vectors, matrices (class
More information