Lecture 24: Rough and Ready Analysis. MATLAB uses function names consistent with most major programming languages For example sqrt sin cos log.

Slides:



Advertisements
Similar presentations
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Advertisements

CMPS 1371 Introduction to Computing for Engineers FUNCTIONS.
Maths for Computer Graphics
Lecture 6 MATLAB functions Basics of Built-in Functions, Help Feature, Elementary Functions (e.g., Polynomials, Trigonometric Functions), Data Analysis,
Lecture 4 Sept 8 Complete Chapter 3 exercises Chapter 4.
Concatenation MATLAB lets you construct a new vector by concatenating other vectors: – A = [B C D... X Y Z] where the individual items in the brackets.
Lecture 4 Sept 7 Chapter 4. Chapter 4 – arrays, collections and indexing This chapter discusses the basic calculations involving rectangular collections.
Lecture 2 MATLAB fundamentals Variables, Naming Rules, Arrays (numbers, scalars, vectors, matrices), Arithmetical Operations, Defining and manipulating.
Builtin and user defined functions
1 Introduction to MATLAB MATLAB is all of the following: 1.Computational environment 2.Plotting software 3.Programming language Typical applications: 1.Calculations.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Predefined MATLAB Functions ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Recap Graphic Window Edit Window Start Button Matrices in MATLAB Scalar Operations Order of Operations Array Operations Matrix Addition Matrix Multiplication.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
Introduction to Engineering MATLAB – 1 Introduction to MATLAB Agenda Introduction Arithmetic Operations MATLAB Windows Command Window Defining Variables.
MATLAB An Introduction to MATLAB (Matrix Laboratory) 1.
Matlab for Engineers Built-in Matlab Functions Chapter 3.
INTRODUCTION TO MATLAB LAB# 01
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
MATLAB Basics. The following screen will appear when you start up Matlab. All of the commands that will be discussed should be typed at the >> prompt.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
1 Lab 2 of COMP 319 Lab tutor : Shenghua ZHONG Lab 2: Sep. 28, 2011 Data and File in Matlab.
Introduction to Matlab Module #2 Page 1 Introduction to Matlab Module #2 – Arrays Topics 1.Numeric arrays (creation, addressing, sizes) 2.Element-by-Element.
Matlab for Engineers Manipulating Matlab Matrices Chapter 4.
Recap Script M-file Editor/Debugger Window Cell Mode Chapter 3 “Built in MATLAB Function” Using Built-in Functions Using the HELP Feature Window HELP.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Lec-10 Manipulations of Matlab Matrices. Built-in functions The chapter will be covered quickly There are quite a few built-in functions in MATLAB – If.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
(The Transpose Operator) 1 >> C=[ ; ; ] C = >> D=C' D =
Array Creation ENGR 1187 MATLAB 2. Today’s Topics  Arrays: What are they?  Vectors  Matrices  Creating Arrays.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
Introduction to Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
1 An Introduction to R © 2009 Dan Nettleton. 2 Preliminaries Throughout these slides, red text indicates text that is typed at the R prompt or text that.
CMPS 1371 Introduction to Computing for Engineers VECTORS.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Manipulating MATLAB Vector, Matrices 1. Variables and Arrays What are variables? You name the variables (as the programmer) and assign them numerical.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
ENG College of Engineering Engineering Education Innovation Center 1 Arrays in MATLAB Topics Covered: 1.Creating arrays of numbers vectors matrices.
Some “What’s the output” questions to get the day started… >>A = [1 2 3; 3 5 6] This statement stores the matrix: 1. A= 2. A= 3. A= 4. A= Ask Garvin’s.
Introduction To MATLAB
Arithmetic Operations
Introduction to Matlab
ECE 1304 Introduction to Electrical and Computer Engineering
Manipulating MATLAB Matrices Chapter 4
Numeric, Cell and Structural Arrays One of the strenghts of MATLAB is the capabilty to handle collection of numbers called ARRAYS. MATLAB refers to scalars,
ECE 1304 Introduction to Electrical and Computer Engineering
Built-in MATLAB Functions Chapter 3
Computer Simulation Lab
Vectors and Matrices Chapter 2 Attaway MATLAB 4E.
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
Vectors and Matrices I.
2.2 Introduction to Matrices
Fourth Year – Software Engineering
Communication and Coding Theory Lab(CS491)
Arrays and Matrices in MATLAB
Stat 251 (2009, Summer) Lab 1 TA: Yu, Chi Wai.
Introduction to Matlab
Vectors and Matrices Chapter 2 Attaway MATLAB 4E.
Matlab Basics Tutorial
Matrices in MATLAB Dr. Risanuri Hidayat.
EECS Introduction to Computing for the Physical Sciences
Computer Simulation Lab
CHAPTER 3 Built-in MATLAB Functions
Presentation transcript:

Lecture 24: Rough and Ready Analysis

MATLAB uses function names consistent with most major programming languages For example sqrt sin cos log

Function Input can be either scalars or matrices

Some functions return multiple results size function determines the number of rows and columns

You can assign names to the output

Nesting Functions

There are functions for almost anything you want to do Use the help feature to find out what they are and how to use them From the command window From the help selection on the menu bar

Elementary Math Functions abs(x)absolute value sign(x)plus or minus exp(x)e x log(x) natural log log10(x)log base 10

Rounding Functions round(x) fix(x) floor(x) ceil(x)

Discrete Mathematics factor(x) gcd(x,y) greatest common denominator lcm(x) lowest common multiple rats(x) represent x as a fraction factorial(x) primes(x) isprime(x)

Trigonometric Functions sin(x)sine cos(x)cosine tan(x)tangent asin(x)inverse sine sinh(x)hyperbolic sine asinh(x)inverse hyperbolic sine sind(x)sine with degree input asind(x)inverse sin with degree output

Data Analysis max(x) min(x) mean(x) median(x) sum(x) prod(x) sort(x)

When x is a matrix, the max is found for each column

max valueelement number where the max value occurs Returns both the smallest value in a vector x and its location in vector x.

Vector of maximums Vector of row numbers Returns a row vector containing the minimum element from each column of a matrix x, and returns a row vector of the location of the minimum in each column of matrix x.

Determining Matrix Size size(x)number of rows and columns length(x)biggest dimension

Variance and Standard Deviation std(x) var(x)

Random Numbers rand(n) Returns an n by n matrix of random numbers between 0 and 1 rand(n,m) Returns an n by m matrix of random numbers These random numbers are evenly distributed

Manipulating Matrices Defining matrices A matrix can be defined by typing in a list of numbers enclosed in square brackets. The numbers can be separated by spaces or commas. New rows are indicated with a semicolon. A = [ 3.5 ]; B = [1.5, 3.1]; or B =[ ]; C = [-1, 0, 0; 1, 1, 0; 0, 0, 2];

Manipulating Matrices Defining matrices Define a matrix by using another matrix that has already been defined. Reference an element in a matrix Both row and column indices start from 1. B = [1.5, 3.1]; S = [3.0, B] S = [3.0, 1.5, 3.1]; T = [1 2 3; S] S = T = S(2) T(2, 3) T(5) The element value on row 2 and column 3 of matrix T Count down column 1, then down column 2, and finally down column 3 to the correct element of matrix T.

Manipulating Matrices Change values in a matrix S(2) = -1.0; changes the 2nd value in the matrix S from 1.5 to -1.0 Extend a matrix by defining new elements. S = T = S(4) = 5.5; Extend the matrix S to four elements instead of three. S(8) = 9.5; Matrix S will have eight values, and the values of S(5), S(6), S(7) will be set to 0. T(3, 3) = 10; T(4, 5) = 20;

Manipulating Matrices Using the colon operator Define an evenly spaced matrix H = 1:8 --- The default spacing is 1 time = 0.0:0.5: The middle value becomes the spacing. Extract data from matrices x = M( :, 1) --- extract column 1 from matrix M y = M( :, 4) --- extract column 4 from matrix M z = M(2, : ) --- extract row 2 from matrix M a = M(2:3, : ) --- extract rows 2 and 3 from matrix M b = M( :, 2:4) --- extract column 2 to column 4 from matrix M c = M(2:3, 3:5) --- extract not whole rows or whole columns from matrix M Converts a two dimensional matrix to a single column M( : ) M =

Practice Question Solution: C