Copyright © 2005. The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Maths for Computer Graphics
Introduction to Matlab. I use Matlab for: Data analysis Data plotting Image Analysis Also – Simulations (solving odes/pdes/finite element methods) – Minimisations,
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
EGR 106 – Week 3 – More on Arrays Brief review of last week Additional ideas: – Special arrays – Changing an array – Some array operators – Character arrays.
Part 3 Chapter 8 Linear Algebraic Equations and Matrices PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The.
Linear Simultaneous Equations
Matrix Mathematics in MATLAB and Excel
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Part 1 Chapter 2 MATLAB Fundamentals
MATLAB Fundamentals.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
MATLAB and SimulinkLecture 11 To days Outline  Introduction  MATLAB Desktop  Basic Features  Branching Statements  Loops  Script file / Commando.
Creating scalars, vectors, matrices Ex1 & 2. Dot Product & Cross Product Ex3. Plotting Graphs Ex4. Conversion Table Ex5. Plotting functions Finishing Ex4.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
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.
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.
Lecture 28: Mathematical Insight and Engineering.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
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 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
10/24/20151 Chapter 2 Review: MATLAB Environment Introduction to MATLAB 7 Engineering 161.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
Working with Arrays in MATLAB
Lecture 1: Matlab Universe
Recap Saving Plots Summary of Chapter 5 Introduction of Chapter 6.
>> x = [ ]; y = 2*x y = Arrays x and y are one dimensional arrays called vectors. In MATLAB all variables are arrays. They allow functions.
Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and Prof. Steve Chapra, Tufts University All.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Slide Copyright © 2009 Pearson Education, Inc. 7.3 Matrices.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
3.6 Solving Systems Using Matrices You can use a matrix to represent and solve a system of equations without writing the variables. A matrix is a rectangular.
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.
CMPS 1371 Introduction to Computing for Engineers VECTORS.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Chapter 4 MATLAB Programming MATLAB Troubleshooting Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Manipulating MATLAB Vector, Matrices 1. Variables and Arrays What are variables? You name the variables (as the programmer) and assign them numerical.
Project Teams Project on Diffusion will be a TEAM project. 34 Students in class so 6 teams of 5 and one Team of 4. Determine members of team and a team.
Designed by Victor Help you improve MATRICES Let Maths take you Further… Know how to write a Matrix, Know what is Order of Matrices,
An Introduction to Programming in Matlab Emily Blumenthal
To add, subtract, multiply, and divide, absolutely follow the mathematical rules. 1. All the rules 2. The element-per-element operator 3. Ex1: graphing.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 3 - Chapter 8 Linear Algebraic Equations and Matrices.
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © The McGraw-Hill Companies, Inc. This work is only for non-profit use by instructors in courses for which this textbook has been adopted.
ENG College of Engineering Engineering Education Innovation Center 1 Arrays in MATLAB Topics Covered: 1.Creating arrays of numbers vectors matrices.
Linear Algebraic Equations and Matrices
12-1 Organizing Data Using Matrices
Chapter 7 Matrix Mathematics
MATLAB DENC 2533 ECADD LAB 9.
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
EECS Introduction to Computing for the Physical Sciences
Working with Arrays in MATLAB
Presentation transcript:

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm III Chapter 2 Numeric Arrays PowerPoint to accompany

Specification of a position vector using Cartesian coordinates. Figure 2.1–1 2-2 The vector p can be specified by three components: x, y, and z, and can be written as: p = [x, y, z]. However, MATLAB can use vectors having more than three elements.

This week Creating vectors Creating vectors row vs column vectors row vs column vectors colon (:) operator colon (:) operator linspace( ) linspace( ) vector math operations vector math operations finding roots of polynomials finding roots of polynomials simple 2D plotting simple 2D plotting Matrices Matrices creating and using script files creating and using script files

What is a vector? A series of values stored in a single variable A series of values stored in a single variable x = [1, 2, 5, 2, 5];  row vector x = [1, 2, 5, 2, 5];  row vector y = [1; 2; 5; 2; 5];  column vector y = [1; 2; 5; 2; 5];  column vector Only one dimension of data Only one dimension of data Two dimensions = Matrix Two dimensions = Matrix The term Array refers to both vectors or matrices The term Array refers to both vectors or matrices

Vectors can be used to represent A 3 dimensional force vector f = [3, 2, 9]; A 3 dimensional force vector f = [3, 2, 9]; An evenly spaced series of values An evenly spaced series of values t = [0:0.001:1]; t = [0:0.001:1]; 1000 samples spaced 1 millisecond apart 1000 samples spaced 1 millisecond apart A math formula applied to a series of values A math formula applied to a series of values wave = cos(2*pi*t); wave = cos(2*pi*t); A polynomial p = [1, 3, -2, 4] A polynomial p = [1, 3, -2, 4] representing x 3 + 3x 2 – 2x + 4 representing x 3 + 3x 2 – 2x + 4

Creating Vectors Typing values in square brackets Typing values in square brackets v = [1, 2, 3]; v = [1, 2, 3]; u = [1; 4; 9]; u = [1; 4; 9]; Using the colon operator Using the colon operator t = [1:0.1:10]; (1, 1.1, 1.2, , 10) t = [1:0.1:10]; (1, 1.1, 1.2, , 10) Using linspace Using linspace x = linspace(1,50, 200); ( 200 points from 1 to 50) x = linspace(1,50, 200); ( 200 points from 1 to 50) Using transpose ( ' ) to convert row to column Using transpose ( ' ) to convert row to column u = u';  turns u from column to row u = u';  turns u from column to row

Vector Math operations Addition, subtraction Addition, subtraction z = u + v;  must have same dimensions z = u + v;  must have same dimensions Multiplication, division by scalar Multiplication, division by scalar p = 3*u; q = v/5; p = 3*u; q = v/5; Element-by-element multiplication Element-by-element multiplication r = u.*v;  dot operator is a must, often forgotten r = u.*v;  dot operator is a must, often forgotten

Polynomial Roots Use vectors when you need to find roots of a polynomial Use vectors when you need to find roots of a polynomial A polynomial p = [1, 3, -2, 4] A polynomial p = [1, 3, -2, 4] representing f(x) = x 3 + 3x 2 – 2x + 4 representing f(x) = x 3 + 3x 2 – 2x + 4 The roots of a polynomial are the values of x such that f(x) = 0 The roots of a polynomial are the values of x such that f(x) = 0 Very useful in many math problems Very useful in many math problems

Plotting with Vectors The idea is to create a vector of x-values The idea is to create a vector of x-values Use a math formula to create y-values Use a math formula to create y-values or just enter x and y values manually or just enter x and y values manually Then plot(x,y); Then plot(x,y); use title('my plot title'); xlabel('text'); ylable('stuff'); to complete the plot use title('my plot title'); xlabel('text'); ylable('stuff'); to complete the plot

Matrices A matrix can be entered directly using ; to start new lines: A matrix can be entered directly using ; to start new lines: M = [1, 2, 3; 4, 5, 6; 7, 8, 9]; M = [1, 2, 3; 4, 5, 6; 7, 8, 9]; A matrix can be constructed from vectors: A matrix can be constructed from vectors: M = [ u', v' ]; M = [ u', v' ]; Matrices can be added, scaled, or element-by- element operated on just as vectors can Matrices can be added, scaled, or element-by- element operated on just as vectors can The colon (:) operator can select parts of a matrix The colon (:) operator can select parts of a matrix

Script files Matlab problem solutions should be developed in a script file to allow easy execution and debugging Matlab problem solutions should be developed in a script file to allow easy execution and debugging Create an m-file in your local workspace Create an m-file in your local workspace Put matlab statements in the file, save Put matlab statements in the file, save At the matlab command line, type the filename (without.m) and the statements in the file execute. At the matlab command line, type the filename (without.m) and the statements in the file execute. Great for all kinds of problem solving Great for all kinds of problem solving