Lecture 1: What is MATLAB?

Similar documents
The MATLAB system The MATLAB system consists of five main parts:

Introduction to MATLAB for CSE390

Fundamentals of MATLAB Usage

Introduction to MATLAB

Script started on Thu 25 Aug :00:40 PM CDT

BRUNO WELFERT Arizona State University AND. R. Kent Nagle. University of South Florida. Edward B. Saff. Vanderbilt University. A.

Introduction to Engineering gii

A General Introduction to Matlab

A QUICK INTRODUCTION TO MATLAB

Computer Programming in MATLAB

A QUICK INTRODUCTION TO MATLAB. Intro to matlab getting started

Dr Richard Greenaway

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline (Cont d) MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An

Outline. CSE 1570 Interacting with MATLAB. Starting MATLAB. Outline. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

PROGRAMMING WITH MATLAB DR. AHMET AKBULUT

Introduction to GNU-Octave

Lecturer: Keyvan Dehmamy

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

Using Matlab in the Chemical Engineering Curriculum at the University of Tennessee. A Workshop presented by David Keffer August 17, 2001

Outline. CSE 1570 Interacting with MATLAB. Outline. Starting MATLAB. MATLAB Windows. MATLAB Desktop Window. Instructor: Aijun An.

ELEMENTARY MATLAB PROGRAMMING

MATLAB Constants, Variables & Expression. 9/12/2015 By: Nafees Ahmed

2.0 MATLAB Fundamentals

1. Register an account on: using your Oxford address

Arithmetic and Logic Blocks

MatLab Just a beginning

Introduction to MATLAB Programming

LAB 1 General MATLAB Information 1

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

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

Introduction to Scientific and Engineering Computing, BIL108E. Karaman

Finding, Starting and Using Matlab

Matlab Workshop I. Niloufer Mackey and Lixin Shen

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

Chapter 1 Introduction to MATLAB

General MATLAB Information 1

Chapter 1 MATLAB Preliminaries

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

Introduction to Matlab

MATLAB The first steps. Edited by Péter Vass

Julia Calculator ( Introduction)

A very brief Matlab introduction

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

MATLAB Workshop Dr. M. T. Mustafa Department of Mathematical Sciences. Introductory remarks

MATLAB QUICK START TUTORIAL

Matlab Tutorial, CDS

Starting MATLAB To logon onto a Temple workstation at the Tech Center, follow the directions below.

Basic stuff -- assignments, arithmetic and functions

AMS 27L LAB #1 Winter 2009

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

Stokes Modelling Workshop

Introduction to MATLAB

University of Alberta

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

Chapter 2. MATLAB Basis

Variables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB:

Ebooks Chemical Engineering

Introduction to MATLAB

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS

Introduction to MATLAB

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

CSI31 Lecture 5. Topics: 3.1 Numeric Data Types 3.2 Using the Math Library 3.3 Accumulating Results: Factorial

MATLAB Introduction. Ron Ilizarov Application Engineer

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

6-1 (Function). (Function) !*+!"#!, Function Description Example. natural logarithm of x (base e) rounds x to smallest integer not less than x

Chapter 3. built in functions help feature elementary math functions data analysis functions random number functions computational limits

Matlab as a calculator

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

PIV Programming. Today s Contents: 1. Matlab Programming 2. An example of PIV in Matlab code 3. EDPIV 4. PIV plugin for ImageJ 5.

Introduction to MATLAB

Welcome to EGR 106 Foundations of Engineering II

Built-in Types of Data

Introduction to Matlab

Introduction to Matlab

PART 1 PROGRAMMING WITH MATHLAB

VARIABLES Storing numbers:

Dr Richard Greenaway

MATLAB is a multi-paradigm numerical computing environment fourth-generation programming language. A proprietary programming language developed by

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

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

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

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

1 Introduction to Matlab

Laboratory 1 Octave Tutorial

Digital Image Analysis and Processing CPE

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

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

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

Math 2250 MATLAB TUTORIAL Fall 2005

George Mason University ECE 201: Introduction to Signal Analysis Spring 2017

Programming in QBasic

A. Matrix-wise and element-wise operations

Evolutionary Algorithms. Workgroup 1

McTutorial: A MATLAB Tutorial

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

CT 229 Java Syntax Continued

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

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

INTRODUCTION TO MATLAB PROGRAMMING Lec 1.1: MATLAB Basics

Transcription:

Lecture 1: What is MATLAB? Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1. MATLAB MATLAB (MATrix LABoratory) is a numerical computing environment and programming language. Developed by MathWorks. MATLAB is widely used to solve engineering and science problems in academic and research institutions as well as the industry. In MATLAB, problems are expressed in familiar mathematical notation. MATLAB is an interactive system whose basic data element is a matrix (remember C/C++ arrays!). Open-source alternative is: GNU Octave. Paid alternative: LabVIEW MathScript 2 1

MATLAB can be used for: Matrix manipulations (math computations). Data analysis, exploration, and plotting. Implementation of algorithms. Creation of user interfaces. Data acquisition. Interfacing with programs written in other languages, (e.g., C, C++, Java, and Fortran). An optional toolbox (with MuPAD symbolic engine) allows accessing symbolic computing. An additional package, Simulink, adds graphical simulation and model-based design. 3 Like a VERY advanced calculator Would you go to an engineering exam without a calculator? 4 2

Solving Simultaneous Equations Find the values of x and y that satisfy the following equations simultaneously : Can be solved by hand to get: x = 1, y = 2 Remember how? 5 Simultaneous Equations Solving simultaneous equations: Can be solved by hand to get: x = 1.2, y = 2.8, z = 0.6 How? 6 3

Solving Simultaneous Equations Many variables: Humans are note good at this. MATLAB (a computer software) is! 7 MATLAB solution 8 4

MATLAB is powerful! We often need to solve systems with 10,000 or 100,000 simultaneous equations (could be non-linear or differential equations too) Can be done very quickly using a computer This is common in engineering Electrical circuits Image recognition Communication systems (MIMO, OFDM, etc) Operations research Mechanics and dynamics, etc 9 MATLAB vs. Programming languages MATLAB is a vector-based numerical analysis language: Can be used as an advanced calculator and graphing tool Also can be used as a programming language This is different than the programming languages you are familiar with (C, C++, ) Can be a little frustrating since it takes time and effort to write code in MATLAB But the code is very effective and can be refined gradually 10 5

Know about MATLAB MATLAB is easy to begin with but needs hard work to master. MATLAB is optimized for performing matrix operations. MATLAB is interpreted for the most part slower than a compiled language such as C++ but interactive and simplifies fixing errors Although primarily procedural, MATLAB does have some object-oriented elements. MATLAB is NOT a general purpose programming language MATLAB is designed for scientific computation and is not suitable for some things (such as parsing text) MATLAB is very useful for data analysis and rapid prototyping, but is not designed for large-scale system development. 11 Let us run MATLAB 12 6

MATLAB Environment 13 MATLAB as a Calculator You can enter expressions at the command line and evaluate them right away. The >> symbols indicate where commands are typed. 14 7

Mathematical Operators 15 Order of Precedence (BEDMAS) B = Brackets E = Exponentials D = Division M = Multiplication A = Addition S = Subtraction Careful using brackets: check that opening and closing brackets are matched up correctly. 16 8

Order of Precedence Precedence First Second Third Fourth Operation Parentheses ( ), evaluated starting with the innermost pair. Exponentiation (power) ^, evaluated from left to right. Multiplication * and division / with equal precedence, evaluated from left to right. Addition + and subtraction - with equal precedence, evaluated from left to right. 17 Exercise: Try it yourself >> 8 + 3*5 23 >> 8 + (3*5) 23 >> (8 + 3)*5 55 >> 4^2-12- 8/4*2 0 >> 4^2-12- 8/(4*2) 3 18 9

Entering Commands MATLAB retains your previous keystrokes. Use the key to scroll back through previous commands. Press the key once to see the previous entry, and so on. Use the key to scroll forward. Edit a line using the and arrow keys, the Backspace key, and the Delete key. Press the Enter key to execute the command. You can copy (highlight & ctrl+c) from Command History window to the Command Window. 19 Built-in Math Constants pi : ratio of circle's circumference to its diameter i 1: Imaginary unit j 1: Imaginary unit Inf : Infinity NaN Not-a-Number intmax Largest value of integer type intmin Smallest value of integer type ans Temporary variable containing the most recent answer eps The accuracy of floating point precision >> 2*pi 6.2832 >> Inf+100000 Inf >> format long g >> 2*pi 6.28318530717959 >> 1+ans 7.28318530717959 20 10

>> 1/0??? >> 0/0??? >> 7/2*i??? >> 7/2i??? Exercise 21 Exercise: Answers >> 1/0 Inf >> 0/0 NaN >> 7/2*i 0 + 3.5000i >> 7/2i 0-3.5000i 22 11

Possible Formats 23 Built-in Functions Like a calculator, MATLAB has many built-in mathematical functions. >> log2(131072) 17 >> sqrt(4) 2 >> abs(-3) 3 >> exp(-1) 0.367879441171442 24 12

Common Built-in Functions 25 Exercise: Discussed Later x = 0:pi/100:2*pi; y = sin(x); plot(x,y) By the way, what is the purpose of the semicolon at the end of the command? 26 13

Exercise: Discussed Later x = 0:pi/100:2*pi; y = sin(x); plot(x,y) 1 0.8 0.6 0.4 0.2 0-0.2-0.4-0.6-0.8-1 0 1 2 3 4 5 6 7 27 Exercise 2: Discussed Later [X,Y] = meshgrid(-10:0.25:10,-10:0.25:10); f = sinc(sqrt((x/pi).^2+(y/pi).^2)); surf(x,y,f); axis([-10 10-10 10-0.3 1]) 28 14

Exercise 2: Discussed Later [X,Y] = meshgrid(-10:0.25:10,-10:0.25:10); f = sinc(sqrt((x/pi).^2+(y/pi).^2)); surf(x,y,f); axis([-10 10-10 10-0.3 1]) 1 0.8 0.6 sinc (R) 0.4 0.2 0-0.2 10 5 10 0 5 0-5 -5 y -10-10 x 29 To Know More: help >> help HELP topics: matlab\general matlab\ops matlab\lang matlab\elmat matlab\randfun matlab\elfun matlab\specfun matlab\matfun matlab\datafun matlab\polyfun matlab\funfun matlab\sparfun matlab\scribe matlab\graph2d matlab\graph3d matlab\specgraph matlab\graphics matlab\uitools matlab\strfun matlab\imagesci matlab\plottools fuzzy\fuzzy images\images signal\signal wavelet\wavelet... - General purpose commands. - Operators and special characters. - Programming language constructs. - Elementary matrices and matrix manipulation. - Random matrices and random streams. - Elementary math functions. - Specialized math functions. - Matrix functions - numerical linear algebra. - Data analysis and Fourier transforms. - Interpolation and polynomials. - Function functions and ODE solvers. - Sparse matrices. - Annotation and Plot Editing. - Two dimensional graphs. - Three dimensional graphs. - Specialized graphs. - Handle Graphics. - Graphical User Interface Tools. - Character strings. - Image and scientific data - Graphical User Interface Tools. - Fuzzy Logic Toolbox - Image Processing Toolbox - Signal Processing Toolbox - Wavelet Toolbox 30 15

Go inside: help >> help elfun Elementary math functions. Trigonometric. sin - Sine. sind - Sine of argument in degrees. sinh - Hyperbolic sine. asin - Inverse sine. asind - Inverse sine, result in degrees. asinh - Inverse hyperbolic sine. cos - Cosine.... Exponential. exp expm1 log log1p log10 log2 pow2 realpow reallog... - Exponential. - Compute exp(x)-1 accurately. - Natural logarithm. - Compute log(1+x) accurately. - Common (base 10) logarithm. - Base 2 logarithm and dissect floating point num. - Base 2 power and scale floating point number. - Power that will error out on complex result. - Natural logarithm of real number. Rounding and remainder. fix - Round towards zero. floor - Round towards minus infinity. ceil - Round towards plus infinity. round - Round towards nearest integer. mod - Modulus (signed remainder after division). rem - Remainder after division. sign - Signum. 31 For a specific function: helpexp >> help exp EXP Exponential. EXP(X) is the exponential of the elements of X, e to the X. For complex Z=X+i*Y, EXP(Z) = EXP(X)*(COS(Y)+i*SIN(Y)). See also expm1, log, log10, expm, expint. Overloaded methods: codistributed/exp fints/exp Reference page in Help browser doc exp 32 16

To Know More: docabs 33 Where do you get more help? Read your textbook. Practice the end-of-chapter examples. References in the syllabus. MATLAB Central: http://www.mathworks.com/matlabcentral/ Google YouTube 34 17