A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.

Slides:



Advertisements
Similar presentations
Department of Computer Science. Definition “An operator is a symbol (+,-,*,/) that directs the computer to perform certain mathematical or logical manipulations.
Advertisements

Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
Maths for Computer Graphics
Introduction to MATLAB
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Expressions and Operators Program Style.
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
Fall 2006AE6382 Design Computing1 Relational and Logical Operators Use relational operators to test two values Work with values of true and false Compare.
Lecture 2 MATLAB fundamentals Variables, Naming Rules, Arrays (numbers, scalars, vectors, matrices), Arithmetical Operations, Defining and manipulating.
Modified Gary Larson Far Side cartoon
1 Chapter 3 Matrix Algebra with MATLAB Basic matrix definitions and operations were covered in Chapter 2. We will now consider how these operations are.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 Introduction to MATLAB MATLAB is all of the following: 1.Computational environment 2.Plotting software 3.Programming language Typical applications: 1.Calculations.
Spreadsheets Objective 6.02
2 Explain advanced spreadsheet concepts and functions Advanced Calculations 1 Sabbir Saleh_Lecture_17_Computer Application_BBA.
Chapter 4: Operators Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills /1436.
Introduction to MATLAB. Windows in MATLAB Command Window – where you enter data, run MATLAB code, and display results Command History - displays a log.
Matlab Chapter 2: Array and Matrix Operations. What is a vector? In Matlab, it is a single row (horizontal) or column (vertical) of numbers or characters.
 Input and Output Functions Input and Output Functions  OperatorsOperators Arithmetic Operators Assignment Operators Relational Operators Logical Operators.
1 Week 3: Vectors and Matrices (Part III) READING: 2.2 – 2.4 EECS Introduction to Computing for the Physical Sciences.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Array Addition  Two arrays can be added if and only if both arrays have exactly the same dimensions.  Assuming the dimension requirement is satisfied,
Introduction to MATLAB CBE 502 Mathematical Methods of Engineering Analysis.
Learner’s Guide to MATLAB® Chapter 2 : Working with Arrays.
Chapter 3: Data Types and Operators JavaScript - Introductory.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
CSE1301 Computer Programming Lecture 5: C Primitives 2 Corrections.
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
Using the Order of Operations Mathematicians have established an order of operations to evaluate an expression involving more than one operation. Finally,
Fall 2006AE6382 Design Computing1 Control Statements in Matlab Topics IF statement and Logical Operators Switch-Case Disp() vs fprintf() Input() Statement.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Introduction to Matlab Module #2 Page 1 Introduction to Matlab Module #2 – Arrays Topics 1.Numeric arrays (creation, addressing, sizes) 2.Element-by-Element.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Performing Calculations—1 of 2 In addition to using queries to retrieve, update, sort, and filter data in a database, you can use a query to perform calculations.
Introduction to MATLAB. CSPP58001 MATLAB MATLAB is is a matrix-based language well suited for carrying out numerical analysis. It has many, many high-
Operators Precedence - Operators with the highest precedence will be executed first. Page 54 of the book and Appendix B list C's operator precedence. Parenthesis.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB Lecture 18.
INTRODUCTION TO MATLAB MATLAB is a software package for computation in engineering, science, and applied mathemat-ics. It offers a powerful programming.
A string is an array of characters Strings have many uses in MATLAB Display text output Specify formatting for plots Input arguments for some functions.
Chapter 4 Controlling Execution CSE Objectives Evaluate logical expressions –Boolean –Relational Change the flow of execution –Diagrams (e.g.,
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
Digital Image Processing Lecture 6: Introduction to M- function Programming.
Digital Image Processing Introduction to M-function Programming.
Fall 2006AE6382 Design Computing1 Control Statements in Matlab Topics IF statement and Logical Operators Switch-Case Disp() vs fprintf() Input() Statement.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Operators & Expressions
Doing math In java.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
MATLAB Constants, Variables & Expression Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB.
ENG College of Engineering Engineering Education Innovation Center 1 Array Operations in MATLAB 1.Types of Matrix arithmetic 2.Dot operators Mathematical.
Array and Matrix Operations Dr. Marco A. Arocha INGE3016-MATLAB Sep 11, 2007, Dic 7,
Relational and Logical Operators EE 201 1C7-2 Spring 2012.
Spreadsheet Calculations Formulas & Functions Computer Applications I.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Operators & Expressions
ECE 1304 Introduction to Electrical and Computer Engineering
Vectorized Code, Logical Indexing
Introduction to MATLAB [Vectors and Matrices] Lab 2
Spreadsheets 2 Explain advanced spreadsheet concepts and functions
Vectors and Matrices Chapter 2 Attaway MATLAB 4E.
Spreadsheets Objective 6.02
Spreadsheets Objective 6.02
Chapter 3: Selection Structures: Making Decisions
Presentation transcript:

A L I MAM M OHAMMAD B IN S AUD I SLAMIC U NIVERSITY C OLLEGE OF S CIENCES D EPARTMENT OF M ATHEMATICS MATLAB 251 : MATH SOFTWARE Introduction to MATLAB

Complement on Matrix manipulation 1 Relational operations Example >> A=rand(4,3) >> B=(A>.2)&(A<0.8) >> C=A.*B >> D=(A~=A(1,1)) 2 Logical operations

I NTRODUCTION TO M ATLAB 3 Operator Precedence You can build expressions that use any combination of arithmetic, relational, and logical operators. Precedence levels determine the order in which MATLAB evaluates an expression. Within each precedence level, operators have equal precedence and are evaluated from left to right. The precedence rules for MATLAB operators are shown in this list, ordered from highest precedence level to lowest precedence level: 1. Parentheses () 2. Transpose (.'), power (.^), complex conjugate transpose ('), matrix power (^) 3. Unary plus (+), unary minus (-), logical negation (~) 4. Multiplication (.*), right division (./), left division(.\), matrix multiplication (*), matrix right division (/), matrix left division (\) 5. Addition (+), subtraction (-) 6. Colon operator (:) 7. Less than ( ), greater than or equal to (>=), equal to (==), not equal to (~=) 8. Element-wise AND (&) 9. Element-wise OR (|)

I NTRODUCTION TO M ATLAB >> a|b&c is similar to >> a|(b&c) >> A = [3 9 5]; >> B = [2 1 5]; >> C = A./B.^2 C = >> C = (A./B).^2 C = Built-in functions and(A,B) equivalent to A & B or(A,B) equivalent to A | B not(A) equivalent to ~A Returns 1 for a vector where all elements of the vector are true (nonzero), and 0 if all elements are not true all Returns 1 for a vector where any element of the vector is true (nonzero), and 0 if no elements are true. any Find indices and values of nonzero elementsfind Sort array elements in ascending or descending ordersort Note: The all and any functions ignore any NaN values in the input arrays

I NTRODUCTION TO M ATLAB >> X = [ ]; >> indices = find(X) >> find(X > 2) >> find(X == 0) >> X = [ ]; >> indices = find(X) >> find(X > 2) >> find(X == 0) Returns the mean values of the elements along different dimensions of an array mean Returns the largest (smallest) element along different dimensions of an array max, min Return the sum of the elements along different dimensions of an array sum Calculates differences between adjacent elements of a vector diff Returns the products of the elements prod Returns the cumulative sum along different dimensions of an array. cumsum Returns the cumulative product along different dimensions of an array. cumprod 4 Some functions

I NTRODUCTION TO M ATLAB Examples >> a=rand(1,5) >> max(a) >> A=rand(3,6) >> max(A) >> max(max(A)) >> sort(a) >> sort(A) >> mean(a) >> mean(A) >> max(A) >> max(max(A)) >> a=rand(1,5) >> max(a) >> A=rand(3,6) >> max(A) >> max(max(A)) >> sort(a) >> sort(A) >> mean(a) >> mean(A) >> max(A) >> max(max(A))

I NTRODUCTION TO M ATLAB b returns the scalar product of the vectors a anddot(a,b) returns the cross product of the vectors a and b.cross(a,b) >> a = [1 2 3]; b = [4 5 6]; >> c = cross(a,b) >> d = dot(a,b) 5. Format function The format Function : controls the numeric format of the values displayed by MATLAB. The function affects only how numbers are displayed, not how MATLAB computes or saves them. >> x = [4/ e-6] format short format short e e e-006 format short g e-006 format long format long e e e-00 format long g e-006 format bank format rat 4/3 1/ Special Characters % : Insert comment line into code >> x=[1:5] %create an row vector from 1 to 5 increment 1