This is…. –Contains syllabus, lecture notes, examples, homework Office Hours –Monday & Tuesday, 11-1 in.

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to Matlab
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
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 Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
CIS 404: Survey and Use of Software Libraries for Scientific Computing Andrew Pershing 3134 Snee Hall
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 7 for Engineers
Matlab Intro. Outline Matlab introduction Matlab elements Types Variables Matrices.
Lecture 2 MATLAB fundamentals Variables, Naming Rules, Arrays (numbers, scalars, vectors, matrices), Arithmetical Operations, Defining and manipulating.
This is…. –Contains syllabus, lecture notes, examples, homework Office Hours –Tuesday & Wednesday, 3-4.
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.
Mathcad Variable Names A string of characters (including numbers and some “special” characters (e.g. #, %, _, and a few more) Cannot start with a number.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
Matlab tutorial course Lesson 2: Arrays and data types
THE MATLAB ENVIRONMENT VARIABLES BASIC COMMANDS HELP HP 100 – MATLAB Wednesday, 8/27/2014
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
Data, graphics, and programming in R 28.1, 30.1, Daily:10:00-12:45 & 13:45-16:30 EXCEPT WED 4 th 9:00-11:45 & 12:45-15:30 Teacher: Anna Kuparinen.
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,
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
CS 404: Survey and Use of Software Libraries for Scientific Computing Andrew Pershing 3134 Snee Hall
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 Workshop 1/10/07 Lesson 1: Matlab as a graphing calculator.
Matrix Arithmetic. A matrix M is an array of cell entries (m row,column ) and it must have rectangular dimensions (Rows x Columns). Example: 3x x.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Intro to Matlab 1.Using scalar variables 2.Vectors, matrices, and arithmetic 3.Plotting 4.Solving Systems of Equations Can be found at:
Introduction to Matlab Module #2 Page 1 Introduction to Matlab Module #2 – Arrays Topics 1.Numeric arrays (creation, addressing, sizes) 2.Element-by-Element.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
Introduction to MATLAB Session 1 Simopekka Vänskä, THL 2010.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
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.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
>> x = [ ]; y = 2*x y = Arrays x and y are one dimensional arrays called vectors. In MATLAB all variables are arrays. They allow functions.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Matlab Fundamentals: working with data.
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.
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.
전자장 1 실험 - Matlab 사용법 - Photonic Systems Laboratory School of EE, Seoul National University Photonic Systems Lab School of EECS, S.N.U.
A rectangular array of numeric or algebraic quantities subject to mathematical operations. The regular formation of elements into columns and rows.
ENG College of Engineering Engineering Education Innovation Center 1 Arrays in MATLAB Topics Covered: 1.Creating arrays of numbers vectors matrices.
MATLAB DENC 2533 ECADD LAB 9.
StatLab Matlab Workshop
Multiplying Matrices.
MATH 493 Introduction to MATLAB
Matlab tutorial course
Matlab Fundamentals: working with data.
Vectors and Matrices I.
Matlab Fundamentals: working with data.
Matlab Intro.
INTRODUCTION TO MATLAB
Multiplying Matrices.
Multiplying Matrices.
This is….
Multiplying Matrices.
Matlab Intro.
Multiplying Matrices.
Presentation transcript:

This is…

–Contains syllabus, lecture notes, examples, homework Office Hours –Monday & Tuesday, 11-1 in 3134 Snee (or by appointment) Registration: –get my signature or CS Undergrad office (303 Upson) –S/U only, 1 credit –Last day to add/drop: Monday, September 10 ! Course Business:

Outline Homework I. Getting started: the Desktop & Workspace Matlab as calculator Variables Arrays Array Operations

Homework I. Download from web page Use a text editor ( er?) to insert answers Paste (DON’T ATTACH) into and send to me by 5PM Wed. next week. No atoms allowed, only bits!

Starting Up On Windows: –Launch from START, or find matlab.exe & double click On UNIX/Linux –Open a terminal, type “matlab” –Problems: “Command not found”--check your path Splash window of 6.X hangs--try “matlab -nojvm”

Windows, windows, and more windows As of 6.0, Matlab has lots of windows inside a “Desktop” The Workspace is the center of the Matlab universe –Holds your data –Waits for your commands –(other windows are fluff) 5.X only has workspace

Basic Math Matlab is a command-line calculator –Simple arithmetic operators + - * / ^ –Basic functions sin(), log(), log10(), exp(), rem() –Constants pi, e

Big deal, a calculator’s $20 Matlab is a fully-functional programming language This means we get variables –name = value Name can be anything made of letters, numbers, and a few symbols (_). Must start with a letter –End line with “;” to avoid output Can also use “;” to put multiple commands on a line –List with who –Delete with clear –More info with whos

1D Arrays--aka Vectors An array is anything you access with a subscript 1D arrays are also known as “vectors” Everything (nearly) in Matlab is a “double array” Create arrays with brackets [ ] Separate elements with commas or spaces Access with ()’s

Regular arrays We can create regularly spaced arrays using “:” –A=st:en produces [st, st+1, st+2, … en] A=1:5 is [ ] A=-3.5:2 is [ ]---note, stops before 2! What happens if en < st ? –Can also insert a “step” size: A=st:step:en A=0:2:6 is [ ] A=5:-2.5:0 is [ ];

Accessing vectors Matlab arrays start at 1 In most languages (C, Java, F77) can only access arrays one element at a time: –a(1)=1; a(2)=2.5; a(3)=-3; etc. In Matlab, can access several elements at a time using an array of integers (aka an index) –a(1:5) is [a(1),a(2),a(3),a(4),a(5)] –a(5:-2:1) is [a(5), a(3), a(1)]

Accessing vectors Index vectors can be variables: –A=10:10:100; I=[1:2:9]; A(I) gives [10,30,50,70,90] –J=[2:2:10];A(J) gives [20,40,60,80,100]; –What does A(I)=A(J) do?

Column vectors “row vectors” are 1-by-n “column vectors” are n-by-1 Row/column distinction doesn’t exist in most languages, but VERY IMPORTANT in MATLAB Create column vectors with semi-colons Can force to column vector with (:) Convert column-to-row and back with transpose (’) Can access the same way as row vectors

2D arrays--matrices From using commas/spaces and semi- colons A=[1 2 3; 4 5 6; 7 8 9]; A(j,k)= j’th row, k’th column A(2:3,1:2)= rows 2 through 3 and columns 1 through 2 A([1,3,4], :)= all of rows 1, 3 and 4 A(:, 1)= first column

“A is m-by-n” means A has m rows and n columns [m,n]=size(A) gets size of A length(a) gets length of vectors. A(1:3,2)=v, v better have length 3 A(1:2:5,2:3)=B, B better be 3-by-2 Size matters

Array Arithmetic C=A+B –if A and B are the same size, C(j,k)=A(j,k)+B(j,k) –If A is a scalar, C(j,k)=A+B(j,k) Same for -

Array Multiplication Multiplication is weird in Matlab –Inherited from linear algebra –To multiply by a scalar, use * –To get C(j,k)=A(j,k)*B(j,k) use “.*” Also applies to “.^” and “./”

Matrix Multiplication C=A*B A is m-by-p and B is p-by-n then C is m-by-n: –C(i,j)= a(i,1)*b(1,j)+a(i,2)*b(2,j)+ … + a(i,p)*b(p,j) Another view: –C(i,j)=a(i,:)*b(:,j); 1-by-p p-by-1 answer is 1-by-1

Matrix Multiplication We’ll defer matrix division for a while matrix multiplication can be useful-- even to those who hate LA –ones(3,1)*[1:5]

Matlab History Matlab stands for “Matrix Laboratory” Developed by from LAPACK--a series of routines for numerical linear algebra Consequences –* is funny, / is even funnier –Matlab does linear algebra really well –Default type is double array

ND arrays Until V5, Matlab arrays could only be 2D Now has unlimited dimensions: –A=ones(2,3,2) –A is a 3D array of ones, with 2 rows, 3 columns, and 2 layers –A(:,:,1) is a 2-by-3 matrix