Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Maths for Computer Graphics
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
CIS 101: Computer Programming and Problem Solving Lecture 2 Usman Roshan Department of Computer Science NJIT.
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.
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
Lecture 2 MATLAB fundamentals Variables, Naming Rules, Arrays (numbers, scalars, vectors, matrices), Arithmetical Operations, Defining and manipulating.
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.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
Lecture 13: M/O/F/ for Engineering Applications - Part 1 BJ Furman 26NOV2012.
Creating scalars, vectors, matrices Ex1 & 2. Dot Product & Cross Product Ex3. Plotting Graphs Ex4. Conversion Table Ex5. Plotting functions Finishing Ex4.
Matlab tutorial course Lesson 2: Arrays and data types
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
MATLAB An Introduction to MATLAB (Matrix Laboratory) 1.
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.
Arrays 1 Multiple values per variable. Why arrays? Can you collect one value from the user? How about two? Twenty? Two hundred? How about… I need to collect.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
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.
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.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Working with Arrays in MATLAB
INTRODUCTION TO MATLAB MATLAB is a software package for computation in engineering, science, and applied mathemat-ics. It offers a powerful programming.
Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Chapter 2 Creating Arrays Legend: MATLAB command or syntax : Blue MATLAB command OUTPUT : LIGHT BLUE.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
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 MATLAB Dr. Hugh Blanton ENTC 4347.
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.
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
Matlab for Engineers Matlab Environment Chapter 2.
MATLAB Lecture 1 염익준. Introduction MATLAB (MATrix LABoratory) a special purpose computer program optimized to perform engineering and scientific calculations.
CMPS 1371 Introduction to Computing for Engineers VECTORS.
Manipulating MATLAB Vector, Matrices 1. Variables and Arrays What are variables? You name the variables (as the programmer) and assign them numerical.
Lecture 12: M/O/F/ for Engineering Applications B Burlingame 27 April 2016.
An Introduction to Programming in Matlab Emily Blumenthal
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.
ENG College of Engineering Engineering Education Innovation Center 1 Arrays in MATLAB Topics Covered: 1.Creating arrays of numbers vectors matrices.
Matlab Programming for Engineers
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to Matlab
MATLAB Basics Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
2) Platform independent 3) Predefined functions
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
Lecture 2 Introduction to MATLAB
Vectors and Matrices I.
Communication and Coding Theory Lab(CS491)
Array Creation ENGR 1181 MATLAB 02.
INTRODUCTION TO MATLAB
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Matlab Basics Tutorial
Presentation transcript:

Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB

MATLAB Special-purpose computer designed for engineering and scientific calculations Short-form for Matrix Laboratory – optimized to perform matrix-based computations Goal Learn how to write clean, efficient and documented MATLAB programs to solve math- bio problems

Advantages and Disadvantages Advantages Ease of use Platform independence Pre-defined functions Plotting capabilities Building graphical user interfaces (GUI) Disadvantages Can be slower than high-level languages such as C++, Fortran, etc. Cost

Anatomy of the MATLAB Environment Current Folder browser MATLAB Editor Workspace Browser Details Window Command Window

Using MATLAB as a calculator Things to note with trig. operations: Input must be enclosed in brackets Inputs must be in radians

Variable Assignment In MATLAB, ‘a=5‘ means that the variable a is being assigned a value of 5 What is the power of variable assignment?

Working Directory Location where you want to save all your files Current working directory Current Folder browser Files in your working directory Click to change the working directory

Arrays Array Collection of data values organized into rows and columns and assigned a single name Types of arrays Vectors: An array with one dimension Matrices: An array with two or more dimensions Specifying the size of an array Rows by columns

Variable Region of memory containing an array is known by a user- specified name Naming variables Similar to naming scripts: Variables must start with a letter and contain only letters, numbers or underscores Good practice to name it with something with meaning Don’t name your variables sin, cos, etc. Make sure characters are unique in the first 63 characters – MATLAB only reads the first 63 characters Variables are case-sensitive

Examples Row vector Column vector Matrix Size of arrays In MATLAB the size of an array is always defined as number of rows by number of columns

Row Vectors There are a few ways to create row vectors a = [1, 2, 3, 4, 5]; OR a = [ ]; What is the output of the command size(a)? You can choose to separate the elements of your vector with a space or a comma Variable name to which the array is assigned When entering array elements, they must be enclosed by square brackets

Column vectors Column vectors are very similar to row, except that each element is in a different row a = [1 ; 2 ; 3 ; 4 ; 5]; a=[ ]’; Don’t forget the square brackets! Semi-colons within the square brackets indicate a NEW row Apostrophe is matrix transpose

Size of an Array Input Output Number of columns Number of rows Size function outputs the size of the array a. Don’t forget the parenthesis since size is a built- in function in MATLAB!

Creating Row Vectors with Shortcut Expressions If Increment is not specified, MATLAB default is 1 Built in function to generate a row vector y v = Initial Value : Increment : Final Value y = linspace( a, b, n ) Start value of vector Ending value of vector Number of elements length( v ) – number of elements in a vector

Array Indexing: Vectors MATLAB Command: a( 3 )  output 3 rd element MATLAB Command: a(3 : 8)  output 3 rd to 8 th elements MATLAB Command: a(7 : end)  output 7 th to last element in a MATLAB Command: a([2, 9])  output 2 nd and 9 th element in a

Go to scripts.pptx Go to plotting.pptx

Creating Matrices Remember that semi-colon within square brackets means go to a new row b = [ ; ; ]; Don’t forget the square brackets! Semi-colons within the square brackets indicate a NEW row Make sure each row has the same number of elements

Array Indexing: Matrices MATLAB Command: A( i, j ) Element from i th row, j th column MATLAB Command: A( m : n, k : l ) Elements from rows m to n and columns k to l MATLAB Command: A( :, 2 : 4 ) All elements from columns 2 to 4 MATLAB Command: A( [ 1 3], : ) All elements from rows 1 and 3 Colon by itself means all elements

Assigning a Scalar to an Array A( 1 : 2, 1 : 2 ) = 1 Assigns elements in the 1 st and 2 nd rows and 1 st and 2 nd columns of A the value of 1

Common Matrix Functionality

Simple Matrix Manipulation What do the following commands do? B = [ A ; u]; D = [ A v ]; A( 2, : ) = [ ]  deletes the 2 nd row of a matrix A

Special Values