Introduction to Matlab

Similar documents
Eng Marine Production Management. Introduction to Matlab

MATLAB is a multi-paradigm numerical computing environment fourth-generation programming language. A proprietary programming language developed by

Introduction to MATLAB

Introduction to Matlab

2.0 MATLAB Fundamentals

Introduction to Matlab

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

A Guide to Using Some Basic MATLAB Functions

MATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline

ENGR 253 LAB #1 - MATLAB Introduction

Chapter 1 Introduction to MATLAB

Introduction to MATLAB

! The MATLAB language

What is Matlab? A software environment for interactive numerical computations

MATLAB. Miran H. S. Mohammed. Lecture 1

Lab of COMP 406 Introduction of Matlab (II) Graphics and Visualization

Introduction to Matlab

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis

Matlab Lecture 1 - Introduction to MATLAB. Five Parts of Matlab. Entering Matrices (2) - Method 1:Direct entry. Entering Matrices (1) - Magic Square

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.

A very brief Matlab introduction

MATLAB = MATrix LABoratory. Interactive system. Basic data element is an array that does not require dimensioning.

Getting started with MATLAB

3 An Introductory Demonstration Execute the following command to view a quick introduction to Matlab. >> intro (Use your mouse to position windows on

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

To start using Matlab, you only need be concerned with the command window for now.

System Design S.CS301

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen.

Matlab Primer. Lecture 02a Optical Sciences 330 Physical Optics II William J. Dallas January 12, 2005

Introduction to MATLAB

1.1 ABOUT MATLAB and MATLAB GUI (Graphical User Interface)

Introduction to GNU-Octave

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:

Learning from Data Introduction to Matlab

STAT/MATH 395 A - PROBABILITY II UW Winter Quarter Matlab Tutorial

1 Introduction to Matlab

Introduction to Unix and Matlab

Summer 2009 REU: Introduction to Matlab

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

Inlichtingenblad, matlab- en simulink handleiding en practicumopgaven IWS

MATLAB/Octave Tutorial

The value of f(t) at t = 0 is the first element of the vector and is obtained by

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation

EE 350. Continuous-Time Linear Systems. Recitation 1. 1

Math 375 Natalia Vladimirova (many ideas, examples, and excersises are borrowed from Profs. Monika Nitsche, Richard Allen, and Stephen Lau)

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

Outline. User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013

ELEN E3084: Signals and Systems Lab Lab II: Introduction to Matlab (Part II) and Elementary Signals

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003

Lab. Manual. Practical Special Topics (Matlab Programming) (EngE416) Prepared By Dr. Emad Saeid

MATLAB SUMMARY FOR MATH2070/2970

Introduction to Engineering gii

Introduction to MatLab. Introduction to MatLab K. Craig 1

Getting To Know Matlab

Introduction to MATLAB Practical 1

An Introduction to MATLAB II

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

Colorado State University Department of Mechanical Engineering. MECH Laboratory Exercise #1 Introduction to MATLAB

Matlab Introduction. Scalar Variables and Arithmetic Operators

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

Lab #1 Revision to MATLAB

HERIOT-WATT UNIVERSITY DEPARTMENT OF COMPUTING AND ELECTRICAL ENGINEERING. B35SD2 Matlab tutorial 1 MATLAB BASICS

Introduction to Matrix Operations in Matlab

CSE/NEUBEH 528 Homework 0: Introduction to Matlab

A Brief Introduction to MATLAB

Eric W. Hansen. The basic data type is a matrix This is the basic paradigm for computation with MATLAB, and the key to its power. Here s an example:

Introduction to Matlab

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

Introduction to MATLAB programming: Fundamentals

MATLAB Basics. Mohamed Taha. Communication Engineering Department Princess Sumaya University Page 1 of 32. Full Screen.

An Introduction to MATLAB See Chapter 1 of Gilat

What is Matlab? The command line Variables Operators Functions

Introduction to MATLAB

1 Week 1: Basics of scientific programming I

Scientific Computing Lecture Series Introduction to MATLAB Programming

MatLab Just a beginning

Introduction to Matlab

University of Alberta

Introduction to MATLAB

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices

LAB 1: Introduction to MATLAB Summer 2011

DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab

Some elements for Matlab programming

AMS 27L LAB #1 Winter 2009

MATLAB Tutorial. Primary Author: Shoumik Chatterjee Secondary Author: Dr. Chuan Li

Introduction to Matlab

Introduction to Python Practical 1

1 Overview of the standard Matlab syntax

Math Scientific Computing - Matlab Intro and Exercises: Spring 2003

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

A Very Brief Introduction to Matlab

This is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms:

EE 301 Signals & Systems I MATLAB Tutorial with Questions

The MATLAB system The MATLAB system consists of five main parts:

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab

AN INTRODUCTION TO MATLAB

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

Transcription:

Introduction to Matlab

What is Matlab? Matlab is a commercial "Matrix Laboratory" package which operates as an interactive programming environment. Matlab is available for PC's, Macintosh and UNIX systems. Matlab is well adapted to numerical experiments. Matlab program and script files (m-files) always have filenames ending with ".m"; The programming language is exceptionally straightforward since almost every data object is assumed to be an array. Graphical output (figure) is available to supplement numerical results. Online help is available from the Matlab prompt (a double arrow) by typing help.

What kind of graphics are possible in Matlab? Polar plot: t=0:.01:2*pi; polar(t,abs(sin(2*t).*cos(2*t))); Line plot: x=0:0.05:5;,y=sin(x.^2);,plot(x,y); Stem plot: x = 0:0.1:4;, y = sin(x.^2).*exp(-x); stem(x,y)

What kind of graphics is possible in Matlab? Mesh plot: z=peaks(25);, mesh(z); Quiver plot: Surface plot: z=peaks(25);, surf(z);, colormap(jet); Contour plot: z=peaks(25);,contour(z,16); 28 January 2003, Matlab tutorial: Joanna Waniek (jowa@soc.soton.ac.uk)

Using Help in Matlab Online help is available from the Matlab prompt (>> a double arrow), both generally (listing of all available commands): >> help [a long list of help topics follows] and for specific commands: >> help fft [a help message on the fft function follows].

What is Matlab? MATLAB consists of: 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 twodimensional and three-dimensional data visualization, image processing, animation, and presentation graphics. (cont d)

What is Matlab? 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.

What is 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? t = 0:pi/100:2*pi; y = sin(t); plot(t,y)

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

Rows and columns are always numbered starting at 1 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] A = [2 7 4; 3 8 9] B=[AA] 2 7 4 2 7 4 2 7 4 3 8 9 2 7 4 2 7 4 3 8 9 3 8 9

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

Matrices a vector x = [1 2 5 1] x = 1 2 5 1 a matrix x = [1 2 3; 5 1 4; 3 2-1] x = 1 5 3 2 1 2 3 4-1

Matrices x(i,j) subscription y=x(2,3) y = 4 whole row y=x(3,:) y = 3 y=x(:,2) whole column y = 2 1 2 2-1

Operators (arithmetic) + addition - subtraction * multiplication / division ^ power complex conjugate transpose.*./.^. element-by-element mult element-by-element div element-by-element power transpose

Operators (relational, logical) == ~= < <= > >= equal & ~ AND OR NOT not equal less than less than or equal greater than greater than or equal pi 3.14159265 j imaginary unit, i same as j ١

Generating Vectors from functions zeros(m,n) MxN matrix of zeros ones(m,n) MxN matrix of ones rand(m,n) MxN matrix of uniformly distributed random numbers on (0,1) x = zeros(1,3) x = 0 0 0 x = ones(1,3) x = 1 1 1 x = rand(1,3) x = 0.9501 0.2311 0.6068

M-files Executing commands in the command window is fine for short scripts; but when dealing with long scripts for complex problem-solving (or when programming) M-files is a must. It allows the user to write MATLAB command in a text file (called M-file) and then MATLAB will open the file and execute the commands exactly as it would if the user typed them at the MATLAB Command Window. The M-file editor is the MATLAB s tool for creating M-files.

m-files % My first M-file We wish to write a MATLAB code (script) to plot f(x) and g(x) on a single graph with labels, title and legend. Where f(x) = sin(x),g(x) = cos(x) x=0:pi/10:2*pi; f=sin(x); g=cos(x); plot(x,f,x,g, ) xlabel( x') ylabel( y') title( sin(x) and cos(x) ) legend( sin(x),'cos(x) )