Introduction to MATLAB The language of Technical Computing.

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

Matlab Intro Simple introduction to some basic Matlab syntax. Declaration of a variable [ ] Matrices or vectors Some special (useful) syntax. Control statements.
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Introduction to Matlab
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
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.
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.
Maths for Computer Graphics
Soft Computing 1 Matlab Tutorial Kai Goebel, Bill Cheetham RPI/GE CRD
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
Introduction to MATLAB
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
Lecture 7 Sept 19, 11 Goals: two-dimensional arrays (continued) matrix operations circuit analysis using Matlab image processing – simple examples Chapter.
Matlab Intro. Outline Matlab introduction Matlab elements Types Variables Matrices.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
What is MATLAB ? MATrix LABratory –Originally, it was a front-end to FORTRAN matrix routines developed in the U. of New Mexico and Stanford –Today.
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
Matlab tutorial course Lesson 2: Arrays and data types
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
Introduction to MATLAB
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
Introduction to MATLAB. Windows in MATLAB Command Window – where you enter data, run MATLAB code, and display results Command History - displays a log.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
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.
Eng Ship Structures 1 Introduction to Matlab.
INTRODUCTION TO MATLAB LAB# 01
Two dimensional arrays in Java Computer Science 3 Gerb Objective: Use matrices in Java.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Introduction MATLAB stands for MATrix LABoratory.  Basics  Matrix Manipulations  MATLAB Programming  Graphics  Image types  Image Processing  Useful.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
Introduction to MATLAB. CSPP58001 MATLAB MATLAB is is a matrix-based language well suited for carrying out numerical analysis. It has many, many high-
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display.
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.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
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.
Introduction to Matlab
CIS 601 Fall 2003 Introduction to MATLAB Longin Jan Latecki Based on the lectures of Rolf Lakaemper and David Young.
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
ECE 351 M ATLAB I NTRODUCTION ( BY T EACHING A SSISTANTS )
Introduction to Matlab Patrice Koehl Department of Biological Sciences National University of Singapore
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
An Introduction to Programming in Matlab Emily Blumenthal
Introduction to MATLAB
L – Modeling and Simulating Social Systems with MATLAB
Introduction to MATLAB
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
Introduction to MATLAB
StatLab Matlab Workshop
Use of Mathematics using Technology (Maltlab)
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Matlab tutorial course
Communication and Coding Theory Lab(CS491)
Matlab Intro.
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Introduction to MATLAB
Simulation And Modeling
MATLAB stands for MATrix LABoratory.
Matlab Intro.
Presentation transcript:

Introduction to MATLAB The language of Technical Computing

MATLAB MATrix LABoratory- Everything is represented by matrices! It is a program for doing Numerical Computation. Also used widely as a programming language to develop tools for Machine Learning.

Why MATLAB? Large toolbox of numeric/image library functions. Very useful for displaying, visualizing data. High-level: focus on algorithm structure, not on low-level details. allows quick prototype development of algorithms. It is an Interpreter, not as fast as compiled code.

The MATLAB Environment

Variables MATLAB treats all variables as matrices. For our purposes a matrix can be thought of as an array, in fact, that is how it is stored. Vectors are special forms of matrices and contain only one row OR one column. Scalars are matrices with only one row AND one column.

MATLAB Programming The symbol “%” is used to indicate a Comment. A “;” at the end of the line implies MATLAB won’t print the output of the statement. Otherwise it will print the output, which is sometimes useful for printing variable values.

MATLAB Programming a = [1,2,3,4] MATLAB Output: a = a=[1,2,3,4]; %Notice the semicolon MATLAB Output:

Command Line MATLAB's command line is like a standard shell: - Up arrow to recall commands without retyping and down arrow to go forward. Opening a new file in editor: >> edit test.m MATLAB source file extension is.m. Running a program : >> test

MATLAB Programming a = [1 2; 3 4]; % Creates a 2x2 matrix The simplest way to create a matrix is to list its entries in square brackets. The ";" symbol separates rows; the (optional) "," separates columns. N = 5 % A scalar v = [1 0 0] % A row vector

MATLAB Programming v = [1; 2; 3] % A column vector v = v’ Transpose a Vector or Matrix(row to column and column to row) v = [] Empty Vector

MATLAB Programming m = zeros(2, 3) Creates a 2x3 matrix of zeros v = ones(1, 3) Creates a 1x3 matrix (row vector) of ones m = eye(3) %Identity matrix (3x3) v = rand(3, 1) Randomly filled 3x1 matrix (column vector)

Indexing in MATLAB REMEBER : Indices always start from “1”, not “0”. Matrix(ROW#,COLUMN#) m(1,3) %1 st row 3 rd column m(2,:) %access whole second row m(:,3) %access whole second column

Operators Assignment = a = b (assign b to a) Addition + a + b Subtraction - a -b Multiplication * or.* a*b or a.*b Division / or./ a/b or a./b Power ^ or.^ a^b or a.^b A “.” means element wise operation

Conditional Structures for i=1:2:7 %Loop from 1 to 7, steps of 2 if(i==3) disp(‘i is 3’) %print output elseif(i==5) disp(‘i is 5’) end

Functions All functions are separate m-files. The first line in a function file must be of this form: function [outarg_1,..., outarg_m] = myfunction(inarg_1,..., inarg_n) The function name should be the same as that of the file.

Function Example myfunction.m function y = myfunction(x) a = [ ]; y = a + x;

Function Example anotherfunction.m function [y, z] = anotherfunction(a, b) y = a + b; z = a - b;

Plotting x=rand(1,100); y=rand(1,100); plot(x,y,’*’);

Plotting To put a label on X-Axis xlabel(‘my x label’); To put a label on Y-Axis ylabel(‘my y label’); To put a Title of the Plot title(‘my title’);

MATLAB Image Processing Image Processing Toolbox is needed. I=imread(‘cute_baby.jpg’); %read Image imshow(I) %show image

MATLAB Image Processing I2=rgb2gray(I); % convert RGB to gray imwrite(I2, ‘cute.jpg’); % save gray image figure, imshow(I2) % image in new figure

MATLAB Image Processing figure,imhist(I2) % show histogram

MATLAB Image Processing From the histogram, we see that the image intensity is missing low values, only high values are present.

MATLAB Image Processing I3 = histeq(I2); %Histogram Equalization figure, imhist(I3);

MATLAB Image Processing figure, imshow(I2) %Original image figure, imshow(I3) % Equalized Image

Help with MATLAB Type help at the MATLAB prompt or help followed by a function name for help on a specific function. Online documentation for MATLAB at the MathWorks website: There are also numerous tutorials online that are easily found with a web search.