Introduction to MATLAB

Slides:



Advertisements
Similar presentations
Section 13-4: Matrix Multiplication
Advertisements

MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Introduction to MATLAB The language of Technical Computing.
Introduction to Matlab
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
CS231A Matlab Tutorial Philip Lee Winter Overview  Goals › Introduction to Matlab › Matlab Snippets › Basic image manipulations › Helpful Matlab.
Maths for Computer Graphics
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
Matlab Matlab is a powerful mathematical tool and this tutorial is intended to be an introduction to some of the functions that you might find useful.
Lecture 7 Sept 19, 11 Goals: two-dimensional arrays (continued) matrix operations circuit analysis using Matlab image processing – simple examples Chapter.
Lecture 6 Sept 15, 09 Goals: two-dimensional arrays matrix operations circuit analysis using Matlab image processing – simple examples.
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.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
EPSII 59:006 Spring Topics Using TextPad If Statements Relational Operators Nested If Statements Else and Elseif Clauses Logical Functions For Loops.
1 Introduction to MATLAB MATLAB is all of the following: 1.Computational environment 2.Plotting software 3.Programming language Typical applications: 1.Calculations.
Chapter 5. Loops are common in most programming languages Plus side: Are very fast (in other languages) & easy to understand Negative side: Require a.
Matlab tutorial course Lesson 2: Arrays and data types
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,
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
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.
Introduction to MATLAB Session 3 Simopekka Vänskä, THL Department of Mathematics and Statistics University of Helsinki 2011.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2010.
Chapter 4 Review: Manipulating Matrices Introduction to MATLAB 7 Engineering 161.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 6: Debugging in MATLAB Monday 15 Sept 2014 EGR 115 Introduction to Computing for Engineers.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
CMPS 1371 Introduction to Computing for Engineers VECTORS.
CSE 455 : Computer Vision MATLAB 101 Getting Started with MATLAB.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Finishing up Chapter 5. Will this code enter the if statement? G=[30,55,10] if G
An Introduction to Programming in Matlab Emily Blumenthal
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to Matlab
Programming in R Intro, data and programming structures
Computer Application in Engineering Design
Signals in Matlab Matlab as a name stands for Matrix Laboratory.
Matlab Training Session 4: Control, Flow and Functions
L – Modeling and Simulating Social Systems with MATLAB
Lecture: MATLAB Chapter 1 Introduction
Introduction to MATLAB
Introduction to Programming for Mechanical Engineers (ME 319)
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
User Defined Functions
Use of Mathematics using Technology (Maltlab)
MATLAB Tutorial Dr. David W. Graham.
MATLAB – What Is It ? Name is from matrix laboratory Powerful tool for
Matlab tutorial course
MATLAB – What Is It ? Name is from matrix laboratory Powerful tool for
MATLAB How to use (using M-files)
Communication and Coding Theory Lab(CS491)
Matlab tutorial course
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Simulation And Modeling
Matlab Basics Tutorial
Presentation transcript:

Introduction to MATLAB Amir Ali Ahmadi Princeton, ORFE Slides/demos prepared in collaboration with: Georgina Hall Princeton, ORFE Some slides/examples courtesy of: Peter J. Ramadge, Ronnie Sircar

The format of this short course I’ll use these PowerPoint slides as a guideline Will run the scripts in MATLAB here for you to see There will be a 90-min tutorial by the TAs right after my lecture so you can try things on your own There is a second short course tomorrow at 6:30 PM My slides and demos will be posted on Blackboard

Getting started To install: http://www.princeton.edu/software/licenses/software/matlab/ Tip: make sure you install the offline version so you can access it when off campus.

Scalar variables and assignments Scalar assignments: Ending semicolon

Basic mathematical functions Basic operations: Exponential functions: Other basic functions that come in handy:

What is more useful than my lecture

Management functions Checking your variables: Clearing stuff… Saving variables:

Vector and matrix manipulation (1/2) Defining a vector/matrix: Size of the data (row, then column) / length Matrix/vector operations: standard component-wise Commonly used matrices:

Vector and matrix manipulation (2/2) Concatenating matrices: Random matrices: Submatrices and elements: MATLAB indexing starts at 1

Logical operations Logical tests: Returns a matrix of same size as A with 0s and 1s : 1 is the condition is met for that entry, 0 is the condition is not met for that entry Find function: Some other basic operations:

Symbolic computation Useful for quick differentiation, integration, evaluation, plotting, etc.

Writing a MATLAB script Easy debugging, access to variables Running the whole script, running sections

Writing a MATLAB function Easy to call multiple times (in a for loop e.g.) Essential for larger projects

Typical call to a MATLAB function from a script

Function handles Quick way of creating a temporary (simple) function without making a new file

Plotting (1/2) Opening a new window for a figure: beginning step size end  

Plotting (2/2) Multiple graphs on one figure: Plotting a surface: ezplot (quick plotting, without defining a vector for input variables): Can also be used to plot level sets: Figure properties, grid, xlabel, … Saving a figure

If/else statements If… then… else… Checking for equalities and inequalities

for/while loops For loops Nested for loops While loops

Practice with for loops Write a script that tests whether a given integer is prime

Practice with for loops Write a script that lists all primes up to an integer N

Vectorized computation Whenever possible, replace for loops with vectorized computation More readable Less error prone Better performance

Vectorized computation

MATLAB toolboxes Collection of m-files for a specific problem domain You will most likely come across some toolboxes depending on your interests

Some basic image processing Converting an image to black and white

Image compression Compressing an image using the singular value decomposition

When stuck, you know where to go… (Can contribute back to the MATLAB community on MATLAB Central)