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.
StatLab Workshop Yale University Maximiliano Appendino, Economics October 18 th, 2013.
Introduction to MATLAB The language of Technical Computing.
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.
Introduction to MATLAB Week 13 – 4/21/09. Instructor: Kate Musgrave Time: Tuesdays 3-5pm Office Hours: Tuesdays 1:30-3pm
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.
Digital Image Processing Lecture3: Introduction to MATLAB.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
MATLAB Lecture One Monday 4 July Matlab Melvyn Sim Department of Decision Sciences NUS Business School
1 Statistical Computing in MATLAB AMS 597 Ling Leng.
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Computer Science 111 Fundamentals of Programming I Overview of Programming.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
Introduction to MATLAB CBE 502 Mathematical Methods of Engineering Analysis.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Chapter 1: Getting Started with MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Introduction to Engineering MATLAB – 2 Introduction to MATLAB - 2 Agenda Defining Variables MATLAB Windows.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
MATLAB Environment ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
OUTLINE Overview Numbers, variables and similar in Matlab
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
訊號與系統 廖文淵 德霖技術學院資訊工程系 Introduction to MATLAB.
ECE 351 M ATLAB I NTRODUCTION ( BY T EACHING A SSISTANTS )
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
The MatLab Language Mathematics Laboratory The MathWorks
MATLAB Lecture 1 염익준. Introduction MATLAB (MATrix LABoratory) a special purpose computer program optimized to perform engineering and scientific calculations.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Tutorial 2 : Matlab - Getting Started.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
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.
Introduction to MATLAB
L – Modeling and Simulating Social Systems with MATLAB
Lecture: MATLAB Chapter 1 Introduction
Statistical Computing in MATLAB
MATLAB Basics Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
Introduction to MATLAB
Introduction to MATLAB
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
Introduction To MATLAB
Introduction to MATLAB
StatLab Matlab Workshop
What Is a Program? A program is like an algorithm, but describes a process that is ready or can be made ready to run on a real computer Retrieved from:
MATH 493 Introduction to MATLAB
Use of Mathematics using Technology (Maltlab)
MATLAB – What Is It ? Name is from matrix laboratory Powerful tool for
MATLAB – What Is It ? Name is from matrix laboratory Powerful tool for
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Lecture 2 Introduction to MATLAB
MATLAB – What Is It ? Name is from matrix laboratory Powerful tool for
Digital Image Processing
Communication and Coding Theory Lab(CS491)
CSE 307 Basics of Image Processing
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Experiment No. (1) - an introduction to MATLAB
Using Script Files and Managing Data
Simulation And Modeling
Introduction To MATLAB
Presentation transcript:

Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore http://www.cs.ucdavis.edu/~koehl/ dbskoeh@nus.edu.sg koehl@cs.ucdavis.edu

What is MATLAB? A high-performance language for technical computing (Mathworks, 1998) The name is derived from MATrix Laboratory Typical uses of MATLAB Mathematical computations Algorithmic development Model prototyping Data analysis and exploration of data (visualization) Scientific and engineering graphics for presentation

Why Matlab? Because it simplifies the analysis of mathematical models It frees you from coding in high-level languages (saves a lot of time - with some computational speed penalties) Provides an extensible programming/visualization environment Provides professional looking graphs

The Matlab Environment Variables; operations on variables Programming Visualization

The Matlab Environment Variables; operations on variables Programming Visualization

The Matlab Environment Workspace Current folder Command Window Command history

Help in Matlab Help Browser -> Product Help Command line: Example: >> help sqrt

The Matlab Environment Variables; operations on variables Programming Visualization

1 2 3 4 5

Variables in Matlab Begin with an alphabetic character: a Case sensitive: a, A No data typing: a=10; a=‘OK’; a=2.5 Default output variable: ans Built-in constants: pi i j Inf clear removes variables who lists variables whos list variables and gives size Special characters : [] () {} ; % : = . ... @

Vectors in Matlab Row vectors >> R1 = [1 6 3 8 5] >> R3 = [-pi : pi/3 : pi] Column vectors >> C1 = [1; 2; 3; 4; 5] >> C2 = R2'

Matrices in Matlab Creating a matrix >> A = [1 2.5 5 0; 1 1.3 pi 4] >> A = [R1; R2] >> A = zeros(10,5) >> A = ones(10,5) >> A = eye(10) Accessing elements >> A(1,1) >> A(1:2, 2:4) >> A(:,2)

Matrix Operations Operators + and – >> X = [1 2 3] >> Y = [4 5 6] >> A = X + Y A= 5 7 9 Operators *, /, and ^ >> Ainv = A^-1 Matrix math is default!

Element wise operations Operators .*, ./, and .^ >> Z = [2 3 4]’ >> B = [Z.^2 Z Z.^0] B= 4 2 1 9 3 1 16 4 1

The Matlab Environment Variables; operations on variables Programming Visualization

M-file programming Script M-Files Automate a series of steps. Share workspace with other scripts and the command line interface. Function M-Files Extend the MATLAB language. Can accept input arguments and return output arguments. Store variables in internal workspace.

M-file programming Always has one script M-File Uses built-in and user-defined functions Created in MATLAB Editor >> edit model.m Run from Command Line Window >> model

Example of script

Example of function

Get input from command window: Input / Output Get input from command window: >> num = input(‘What is the altitude :’) >> str = input(‘Enter name of the planet’,’s’) Display output in command window: String >> disp(‘The answer is:’) String + number: >> disp([‘The value of x is: ‘ num2str(x)])

Operators

Program flow control: For Simple program that sums the squares of all the elements of a matrix A: N = 10; M = 20; A = rand(10,20) Sum = 0; for i = 1:N for j = 1:M Sum = Sum + A(i,j)^2; end Note that this can be done in one line: Sum2 = sum(sum(A.*A));

Program flow control: if Simple program that compares two numbers a and b: set j to 1 if a>b, -1 if a<b, and 0 if a = b: if a > b j = 1; else if a < b j = -1; else j = 0; end

Other useful commands Workspace >> clear >> who >> whos >> close File operations >> ls >> dir >> cd >> pwd >> mkdir

The Matlab Environment Variables; operations on variables Programming Visualization

References Violeta Ivanova, MIT http://web.mit.edu/acmath/matlab/IAP2007/ Experiment with Matlab (Steve Moler): http://www.mathworks.com/moler/exm/chapters.html Matlab: learning by examples http://www.mathworks.com/help/techdoc/matlab_prog/exampleindex.html