Matlab Fundamentals: working with data.

Slides:



Advertisements
Similar presentations
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Advertisements

1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
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.
CS231A Matlab Tutorial Philip Lee Winter Overview  Goals › Introduction to Matlab › Matlab Snippets › Basic image manipulations › Helpful Matlab.
Where to Go Next. Outline Announcements: –Homework IV due Wed. 10/8 by 5, by Extra week for projects Absolutely no exceptions! Answers will be.
Soft Computing 1 Matlab Tutorial Kai Goebel, Bill Cheetham RPI/GE CRD
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.
Division Example 2x - 3y + 4z = 10 x + 6y - 3z = 4 -5x + y + 2z = 3 A*X = B where A = B = >> X = A\B X =
Matlab Intro. Outline Matlab introduction Matlab elements Types Variables Matrices.
This is…. –Contains syllabus, lecture notes, examples, homework Office Hours –Tuesday & Wednesday, 3-4.
Introduction to MATLAB
Where to Go Next. Outline Announcements: –Homework IV due Friday by 5, by Absolutely no exceptions! Answers will be posted on web I will be available.
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.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
January 24, 2005 Lecture 3 - By P. Lin 1 CPET 190 Lecture 3 Problem Solving with MATLAB
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
Sundermeyer MAR 550 Spring Laboratory in Oceanography: Data and Methods MAR550, Spring 2013 Miles A. Sundermeyer Linear Algebra & Calculus Review.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
IC3003 B ASIC S CIENTIFIC C OMPUTING Lecture 1 Monday 08:30-11:30 U204a.
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.
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.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
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.
Basics of MATLAB By DR. Wafaa Shabana
CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation TexPoint fonts used in EMF. Read.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction MATLAB stands for MATrix LABoratory.  Basics  Matrix Manipulations  MATLAB Programming  Graphics  Image types  Image Processing  Useful.
Language Basics and Data Types ● What and why of Matlab. ● Matlab desktop. ● Familiarize ourselves with basics of language. ● Basic types of data that.
This is…. –Contains syllabus, lecture notes, examples, homework Office Hours –Monday & Tuesday, 11-1 in.
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.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
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.
MySQL Importing and creating a database. CSV (Comma Separated Values) file CSV = Comma Separated Values – they are simple text files containing data which.
Files: By the end of this class you should be able to: Prepare for EXAM 1. create an ASCII file describe the nature of an ASCII text Use and describe string.
Array Operations ENGR 1181 MATLAB 4.
CS 401: Applied Scientific Computing with MATLAB Andrew Pershing 3134 Snee Hall
Matlab Introduction  Getting Around Matlab  Matrix Operations  Drawing Graphs  Calculating Statistics  (How to read data)
EGR 115 Introduction to Computing for Engineers MATLAB Basics 3: Array Operations Monday 08 Sept 2014 EGR 115 Introduction to Computing for Engineers.
The Hong Kong Polytechnic University Industrial Centre MatLAB Lesson 1 : Overview & Environment Edward Cheung Room W311g.
Input Output Garbage In, Garbage Out. Outline Announcements: –Homework III: due Today. by 5, by Discuss on Friday. –Homework IV: on web, due following.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 1: Variables & Arrays Wednesday 03 Sept 2014 EGR 115 Introduction to Computing for Engineers.
CSE 455 : Computer Vision MATLAB 101 Getting Started with MATLAB.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Improving performance Matlab’s a pig. Outline Announcements: –Homework I: Solutions on web –Homework II: on web--due Wed. Homework I Performance Issues.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Lecture 12: M/O/F/ for Engineering Applications B Burlingame 27 April 2016.
An Introduction to Programming in Matlab Emily Blumenthal
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
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.
Introduction to Matlab
Matlab review Matlab is a numerical analysis system
Matlab Fundamentals: working with data.
Lecture 2 Introduction to MATLAB
Matlab Fundamentals: working with data.
funCTIONs and Data Import/Export
Demo of Basic Matlab Features
This is….
Presentation transcript:

Matlab Fundamentals: working with data

Outline Announcements Matrix Multiplication ND-arrays Homework I due 9/10, 5PM by e-mail remember--plain text, Subject=CIS 401 Homework Matrix Multiplication ND-arrays Loading, saving, and plotting data

2D arrays--matrices From using commas/spaces and semi-colons 1 2 3 4 5 6 7 8 9 2 3 5 6 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(1:2,2:3)= rows 2 through 3 and columns 1 through 2 A([1,3,2], :)= all of rows 1, 3 and 2 A(:, 1)= first column A(3,:)= last row 1 2 3 4 5 6 7 8 9 1 2 3 7 8 9 4 5 6 1 2 3 4 5 6 7 8 9 1 4 7 1 2 3 4 5 6 7 8 9 7 8 9

Size matters “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 (max of m and n). A(1:3,2)=v, v better have length 3 A(1:2:5,2:3)=B, B better be 3-by-2

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

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) p

Matrix Multiplication Another view: C(i,j)=a(i,:)*b(:,j); 1-by-p p-by-1 answer is 1-by-1 This is a vector (dot) product

Matrix Multiplication Special Cases of A*B Name size(A) size(B) size(C) dot product u’*v 1-by-n (row) n-by-1 (column) linear system b=A*x m-by-n (matrix) outer product X=ones(5,1)*(1:3) Y=(1:5)’*ones(1,3) m-by-1

Matrix Multiplication C=A*B is matrix multiplication If A & B are the same size, can do element-by-element multiplication: C=A.*B C(j,k)=A(j,k)*B(j,k); Analogous operators ./ and .^

Matrix Multiplication We’ll defer matrix division for a while matrix multiplication can be useful--even to those who hate LA outer products are very handy Vectorized ops much faster than writing loops

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

Working with Data Data is central to applied scientific computing Data Program Output Currents SSH Geostropic eq. U,V,plot Weather T,V,M Finite diff. T,V,M in future Bioinfomatics ATCGCGTA… Search for genes Location of genes Electronics Signal FFT Plot of spectrum

Getting Data into Matlab Options Cut & paste, or enter by hand Read from a file

File Types File Type Efficiency (info/byte) Matlab Factor Intangibles ASCII Low Good Easy to edit and view, universal. Binary High Not so good Can’t view, need to know how it was created Proprietary (e.g. Excel) ?? Impossible-to-good Some formats supported, some not .mat Best Careful when loading to avoid variable-name collisions

Loading Simple Text Files “load fname.txt” will create an array fname with the data Each line of fname.txt must have same number of columns Matlab will ignore lines starting with % add to header lines, so Matlab will ignore

Saving data with save save save fname save fname var1 var2 creates matlab.mat with all variables in workspace save fname creates fname.mat with all variables save fname var1 var2 saves only variables var1 & var2 save fname.txt var1 -ascii -tabs -double saves var1 as a table of ASCII numbers called fname.txt

Tutorial 2 Start with table of values in Excel Make the file suitable for Matlab (e.g. a matrix) Save as text Load into Matlab Rearrange the data with Matlab array operations Save data to a .mat file Create a plot of corn prices vs. time

Other help options help fname helpwin Help menu bare-bones help for function fname helpwin help info categorized and available through GUI Help menu More tutorial-like

Summary Matrix mult: “Inner matrix dimensions must agree” Load ASCII or .mat files with load Save data to ASCII or .mat with save Create simple plots with plot Get help with help