Introduction to MATLAB adapted from Dr. Rolf Lakaemper.

Slides:



Advertisements
Similar presentations
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)
Advertisements

Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Introduction to MATLAB The language of Technical Computing.
Introduction to Matlab
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Lab5 (Signal & System) Instructor: Anan Osothsilp Date: 20 Feb 07 Due Date 09 March 07.
CS231A Matlab Tutorial Philip Lee Winter Overview  Goals › Introduction to Matlab › Matlab Snippets › Basic image manipulations › Helpful Matlab.
Data Analytics and Dynamic Languages Lee E. Edlefsen, Ph.D. VP of Engineering 1.
Soft Computing 1 Matlab Tutorial Kai Goebel, Bill Cheetham RPI/GE CRD
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
Getting started with Matlab Numerical Methods Appendix B help/techdoc/learn_matlab/learn_matlab.html.
1 Introduction to MatLab MatLab stands for Matrix Laboratory. As the name suggests most of the programming operations have as input or output a matrix.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Basis of Mathematical Modeling LECTURE 1 Computation and visualization in MATLAB Dr. N.K. Sakhnenko, PhD, Professor Associate.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
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.
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
Eng Ship Structures 1 Introduction to Matlab.
INTRODUCTION TO MATLAB LAB# 01
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course.
Basics of MATLAB By DR. Wafaa Shabana
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Matlab Tutorial (material available at 1 Dr. Jim Martin Associate Professor School of Computing.
MATLAB – PT1 The purpose of this workshop is to get you started and to have fun with MATLAB! Let’s talk a little and decide on what we will be covering.
CIS 595 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
A (VERY) SHORT INTRODUCTION TO MATLAB J.A. MARR George Mason University School of Physics, Astronomy and Computational Sciences.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
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.
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.
MATLAB ……………….matrix laboratory. Bhushan D Patil PhD Research Scholar Department of Electrical Engineering Indian Institute of Technology, Bombay Powai,
Matlab.
Introduction to MATLAB
Signals in Matlab Matlab as a name stands for Matrix Laboratory.
Introduction to Matlab
Introduction to Mat lab
Lecture: MATLAB Chapter 1 Introduction
Introduction to MATLAB
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
(Mohammed Sami) Ashhab
Introduction To MATLAB
Introduction to MATLAB
Simulation And Modeling
Digital Image Processing using MATLAB
Part I – Matlab Basics.
Use of Mathematics using Technology (Maltlab)
MATLAB Tutorial Dr. David W. Graham.
CSE 307 Basics of Image Processing
Introduction to MATLAB
Matlab Basic Dr. Imtiaz Hussain
Simulation And Modeling
Presentation transcript:

Introduction to MATLAB adapted from Dr. Rolf Lakaemper

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

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

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 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: (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)

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

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

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

Matrices

Some operators must be handled with care: A = [1 2 ; 4 5] B = A * A prints B = A.* A prints Element by element multiplication

Submatrices A matrix can be indexed using another matrix, to produce a subset of its elements: a = [ ] b = [3 5 6] c = a(b):

Submatrices To get a subsection of a matrix, we can produce the index matrix with the colon operator: a(2:5) prints ans = 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.

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

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

loops Once again: AVOID LOOPS

Images Example

Images Images can be treated as matrices !

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

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

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

Plotting Commands covered: plot, xlabel, ylabel, title grid, axis, stem, subplot xlabel('time (sec)'); ylabel('step response'); title('My Plot'); Eg:To plot more than one graph on the screen, use the command subplot(mnp) which partitions the screen into an mxn grid where p determines the position of the particular graph counting the upper left corner as p=1. For example, subplot(211),semilogx(w,magdb); subplot(212),semilogx(w,phase);

3D - Plotting example x=[0:10]; y=[0:10]; z=x’*y; mesh(x,y,z); title(‘3-D Graph’);

Convolution For example, x = [ ];  [ ] h = [ ];  [ ] conv(x,h) yields y = [ ]. stem(y); ylabel(‘Conv'); xlabel(‘sample number’);

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

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

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

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 !