Introduction to MATLAB

Slides:



Advertisements
Similar presentations
The Complete Technical Analysis and Development Environment An attractive alternative to MATLAB and GAUSS - Physics World.
Advertisements

Tutorial on Matlab and OpenCV Rui Ma TA of CMPT 414 May 14, 2013 Office hours: Fridays 11:00-12:00, CSIL TA Office 1 (ASB 9838)
Introduction to MATLAB The language of Technical Computing.
Programming Paradigms and languages
Data Analytics and Dynamic Languages Lee E. Edlefsen, Ph.D. VP of Engineering 1.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
What is R By: Wase Siddiqui. Introduction R is a programming language which is used for statistical computing and graphics. “R is a language and environment.
Antigone Engine Kevin Kassing – Period
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
CIS 601 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
You can make this in matlab!. Matlab Introduction and Matrices.
Introduction to M ATLAB EE 100 – EE Dept. - JUST.
Eng Advanced Marine Vehicles Todays agenda: Lab tomorrow at 2pm (structures lab) ‏ Advanced Marine Party Introduction to Matlab.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Eng Ship Structures 1 Introduction to Matlab.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 2.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Chapter 1: Brief Overview of MATLAB MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Matlab Tutorial (material available at 1 Dr. Jim Martin Associate Professor School of Computing.
MATLAB Tutorial EE313 Signals and Systems Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Jeff Andrews.
CIS 595 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
A (VERY) SHORT INTRODUCTION TO MATLAB J.A. MARR George Mason University School of Physics, Astronomy and Computational Sciences.
Linear Algebra Libraries: BLAS, LAPACK, ScaLAPACK, PLASMA, MAGMA
CMPS1371 Introduction to Computing for Engineers IMAGES.
CIS 601 Fall 2003 Introduction to MATLAB Longin Jan Latecki Based on the lectures of Rolf Lakaemper and David Young.
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
CSE 455 : Computer Vision MATLAB 101 Getting Started with MATLAB.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
CIS 595 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
“Moh’d Sami” AshhabSummer 2008University of Jordan MATLAB By (Mohammed Sami) Ashhab University of Jordan Summer 2008.
Matlab Tutorial (material available at 1 Dr. Jim Martin Associate Professor School of Computing.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
CST 1101 Problem Solving Using Computers
Matlab.
Learning to Program D is for Digital.
Introduction to Matlab
Introduction to Mat lab
Computer 4 JEOPARDY Bobbie, Sandy, Trudy.
Lecture: MATLAB Chapter 1 Introduction
MATLAB Basics Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
Introduction to MATLAB
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
(Mohammed Sami) Ashhab
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
Simulation And Modeling
Digital Image Processing using MATLAB
Part I – Matlab Basics.
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:
Use of Mathematics using Technology (Maltlab)
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
a = imread(‘picture.jpg’); imshow(a);
Digital Image Processing
Communication and Coding Theory Lab(CS491)
CSE 307 Basics of Image Processing
Matlab Basic Dr. Imtiaz Hussain
Tonga Institute of Higher Education IT 141: Information Systems
Experiment No. (1) - an introduction to MATLAB
Simulation And Modeling
Tonga Institute of Higher Education IT 141: Information Systems
Laboratory in Oceanography: Data and Methods
Presentation transcript:

Introduction to MATLAB CIS 350 – 1 Introduction to MATLAB Dr. Rolf Lakaemper

This introduction will give MATLAB This introduction will give a brief overview, it’s not a MATLAB tutorial ! Some basic ideas Main advantages and drawbacks compared to other languages

MATLAB What Is MATLAB? MATLAB (MATrix LABoratory) high-performance language for technical computing computation, visualization, and programming in an easy-to-use environment Typical uses include: Math and computation Algorithm development Modelling, simulation, and prototyping Data analysis, exploration, and visualization Scientific and engineering graphics Application development, including Graphical User Interface building

A good choice for vision program development because: Why MATLAB A good choice for vision program development because: Easy to do very rapid prototyping Quick to learn, and good documentation A good library of image processing functions Excellent display capabilities Widely used for teaching and research in universities and industry Another language to impress your boss with !

• Slow for some kinds of processes • Not geared to the web Why not MATLAB Has some drawbacks: • Slow for some kinds of processes • Not geared to the web • Not designed for large-scale system development

MATLAB consists of: MATLAB Components The MATLAB language a high-level matrix/array language with control flow statements, functions, data structures, input/output, and object-oriented programming features. The MATLAB working environment the set of tools and facilities that you work with as the MATLAB user or programmer, including tools for developing, managing, debugging, and profiling Handle Graphics the MATLAB graphics system. It includes high-level commands for two-dimensional and three-dimensional data visualization, image processing, animation, and presentation graphics. …(cont’d)

… MATLAB Components The MATLAB function library. a vast collection of computational algorithms ranging from elementary functions like sum, sine, cosine, and complex arithmetic, to more sophisticated functions like matrix inverse, matrix eigenvalues, Bessel functions, and fast Fourier transforms as well as special image processing related functions The MATLAB Application Program Interface (API) a library that allows you to write C and Fortran programs that interact with MATLAB. It include facilities for calling routines from MATLAB (dynamic linking), calling MATLAB as a computational engine, and for reading and writing MAT-files.

Some facts for a first impression MATLAB Some facts for a first impression Everything in MATLAB is a matrix ! MATLAB is an interpreted language, no compilation needed (but possible) MATLAB does not need any variable declarations, no dimension statements, has no packaging, no storage allocation, no pointers Programs can be run step by step, with full access to all variables, functions etc.

What does Matlab code look like? A simple example: a = 1 while length(a) < 10 a = [0 a] + [a 0] end which prints out Pascal’s triangle: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 1 7 21 35 35 21 7 1 1 8 28 56 70 56 28 8 1 1 9 36 84 126 126 84 36 9 1 (with “a=” before each line).

What does Matlab code look like? Another simple example: t = 0:pi/100:2*pi; y = sin(t); plot(t,y)

EVERYTHING IN MATLAB IS A MATRIX ! What does Matlab code look like? Another simple example: t = 0:pi/100:2*pi; y = sin(t); plot(t,y) Remember: EVERYTHING IN MATLAB IS A MATRIX ! creates 1 x 200 Matrix Argument and result: 1 x 200 Matrix

Matrices

Rows and columns are always numbered starting at 1 Matrices Rows and columns are always numbered starting at 1 Matlab matrices are of various types to hold different kinds of data (usually floats or integers) A single number is really a 1 x 1 matrix in Matlab! Matlab variables are not given a type, and do not need to be declared Any matrix can be assigned to any variable

Building matrices with [ ]: A = [2 7 4] A = [2; 7; 4] B = [ A A ] 2 7 4 2 7 4 2 7 4 3 8 9 ?

Building matrices with [ ]: A = [2 7 4] A = [2; 7; 4] B = [ A A ] 2 7 4 2 7 4 2 7 4 3 8 9 2 7 4 2 7 4 3 8 9 3 8 9

Matrices

Some operators must be handled with care: A = [1 2 ; 4 5] Matrices Some operators must be handled with care: A = [1 2 ; 4 5] B = A * A prints 9 12 24 33 B = A .* A prints 1 4 16 25 Element by element multiplication

Submatrices A matrix can be indexed using another matrix, to produce a subset of its elements: a = [100 200 300 400 500 600 700] b = [3 5 6] c = a(b): 300 500 600

This works in 2-D as well, e.g. c(2:3, 1:2) produces a Submatrices To get a subsection of a matrix, we can produce the index matrix with the colon operator: a(2:5) prints ans = 200 300 400 500 This works in 2-D as well, e.g. c(2:3, 1:2) produces a 2 x 2 submatrix. The rows and columns of the submatrix are renumbered.

‘for’ loops in MATLAB iterate over matrix elements: b = 0 for i = [ 3 9 17] b = b + i; end Result: 29 Note: The MATLAB way to write that program would have been: b = sum([ 3 9 17]); Avoid loops if possible !

The typical ‘for’ loop looks like: for i = 1:6 … end loops The typical ‘for’ loop looks like: for i = 1:6 … end Which is the same as: for i = [1 2 3 4 5 6]

loops Once again: AVOID LOOPS

So why MATLAB and IMAGE PROCESSING ? Images So why MATLAB and IMAGE PROCESSING ?

Images can be treated as matrices !

a = imread(‘picture.jpg’); imshow(a); Images Loading an image: a = imread(‘picture.jpg’); imshow(a);

Images Image (=matrix) size: size(a): 384 512 3 R G B 384 512

Images Color image: 3D Matrix of RGB planes

Images Show RED plane: a(:,:,2:3) = 0; imshow(a);

Images Show GREEN plane: a(:,:,[1 3]) = 0; imshow(a);

Images Show BLUE plane: a(:,:,1:2) = 0; imshow(a);

Advanced: Shuffling columns Images Advanced: Shuffling columns rn = rand(1,512); [rn1,i] = sort(rn); b = a(:,i,:); imshow(b);

Images

By the way… MATLAB can also handle Movies 3D objects …

MATLAB is a mighty tool to manipulate matrices Conclusion MATLAB is a mighty tool to manipulate matrices Images can be treated as matrices MATLAB is a mighty tool to manipulate images

MATLAB should be used to code software prototypes In my opinion… MATLAB should be used to code software prototypes Research is mostly about prototypes, not runtime-optimized software MATLAB should be used in research

Algorithm development time is drastically shorter in MATLAB In my opinion… MATLAB prototypes must be re-coded (e.g. in C++) if there’s need for speed Algorithm development time is drastically shorter in MATLAB

Conclusion CONCLUSION: Give it a try !