Prof. N. P. Jadhav Presented by. Overview of MATLAB environment MATLAB is an interactive, matrix-based system for scientific and engineering numeric computation.

Slides:



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

MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to Engineering MATLAB – 11 Plotting - 4 Agenda Multiple curves Multiple plot.
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Lecture (4) Plotting & Programming (1) Eng. Osama Talaat 1.
Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Matrix Manipulation and 2D Plotting
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 4.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
MATLAB - Lecture 22A Two Dimensional Plots / Chapter 5 Topics Covered:
Vectors and Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Introduction to Matlab 332:202 Discrete Mathematics Spring 2007.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Lecture 2 MATLAB fundamentals Variables, Naming Rules, Arrays (numbers, scalars, vectors, matrices), Arithmetical Operations, Defining and manipulating.
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.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
Part 1 Chapter 2 MATLAB Fundamentals
MATLAB Fundamentals.
1 Introduction to MATLAB MATLAB is all of the following: 1.Computational environment 2.Plotting software 3.Programming language Typical applications: 1.Calculations.
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
1 Statistical Computing in MATLAB AMS 597 Ling Leng.
PLOTS AND FIGURES DAVID COOPER SUMMER Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
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.
INTRODUCTION TO MATLAB LAB# 01
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
Master in Optical Fiber Communications and Photonic Technologies Foundations of Digital Transmission - Fall quarter Introduction to Matlab.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
Plot (x-values, y-values) >> x = linspace (-3, 3, 20); >> x = linspace (-3, 3, 20); >> y = 2*x – 1; >> y = 2*x – 1; >> plot (x, y) >> plot (x, y)
Computer Simulation Lab Electrical and Computer Engineering Department SUNY – New Paltz SUNY-New Paltz “Lecture 2”
Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and Prof. Steve Chapra, Tufts University All.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
CS100A, Fall 1998, Lecture 191 CS100A, Fall 1998 Lecture 19, Thursday Nov 05 Matlab Concepts: Matlab arrays Matlab subscripting Matlab plotting.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
EGR 106 – Week 5 – 2-D Plots Question : Why do engineers use plots? Answer : To analyze, visualize, and present data. Matlab has many useful plotting options.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
ECE 1304 Introduction to Electrical and Computer Engineering
Introduction to MATLAB
Statistical Computing in MATLAB
Lecture 25: Exploring data
Matrices and Arrays.
MATLAB DENC 2533 ECADD LAB 9.
Introduction To MATLAB
EEE 244 Numerical Methods In Electrical Engineering
Part 1 Chapter 2 MATLAB Fundamentals
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files)
Introduction to MATLAB Plotting LAB 3
INTRODUCTION TO MATLAB
Plotting Signals in MATLAB
Part 1 Chapter 2 MATLAB Fundamentals
Announcements P3 due today
How to Use MATLAB A Brief Introduction.
Introduction to Matlab
Presentation transcript:

Prof. N. P. Jadhav Presented by

Overview of MATLAB environment MATLAB is an interactive, matrix-based system for scientific and engineering numeric computation and visualization. What is MATLAB ? Provides interactive environment with hundreds of built in functions for technical computations, graphics, animations. Built in functions which provide excellent tools for linear algebra, data analysis, signal processing, optimization, ODE systems, control systems and many more…

Use of MATLAB includes – Math and computation Algorithm development Data acquisition Modeling, simulation and prototyping Data analysis, exploration and visualization Scientific and engineering graphics Application development, including graphical user interface building

Getting Started Starting of MATLAB UIW Method 1 Start > All Programs > MATLAB > MATLAB (icon) Method 2 Desktop > MATLAB icon

Getting Started Click on the MATLAB icon on your PC desktop

Getting Started A = [ ; ; ; ] Note 1: Separate the elements of row with blanks or commas. Note 2: Use semicolon (;) to indicate the end of each row. Note 3: Surround the entire list of elements with square brackets, [ ] Hit enter, to display the result as follows, A = Matrix : A = [ 16,3,2,13; 5,10,11,8; 9,6,7,12; 4,15,14,1 ] OR

Getting Started Magic square of matrix : Commands : sum, transpose, diagonal of matrix sum(A) …………. hit enter for result A` …………. hit enter for result sum(A` )` …………. hit enter for result diag(A) …………. hit enter for result sum(diag(A)) …………. hit enter for result sum(diag(fliplr(A))) …………. hit enter for result this will flips a matrix from left to right.

Magic square of matrix : Commands : subscripts of matrix Element of row i & column j of A is denoted by A(i, j) Getting Started A ( i, j ) number in i rownumber in j column represent a row represent a column

Magic square of matrix : Commands : subscripts of matrix Getting Started e.g. A(1,4) means, a number in a matrix which is exactly at 1 st row and 4 th column. A =

Magic square of matrix : Commands : subscripts of matrix Getting Started e.g. A(1,4) + A(2,4) + A(3,4) + A(4,4) A =

Swapping columns in Matrix : Getting Started observee.g. Type : B = magic(4) Type : A = B (:, [ ] ) A = B (:, [ ] ) compute the result 1 st column remains as it is 3 rd column becomes 2 nd 2 nd column becomes 3 rd 4 th column remains as it is

Colon Operator : integer Getting Started e.g. 1 : 10 Row vector containing integers from 1 to 10, having increment of 1 i.e. unit spacing. result decremente.g. 100 : -7 : 50 Obtain non unit spacing, with decrement of -7. result

Colon Operator : Getting Started incremente.g. -5 : 0.05 : 5 Obtain non unit spacing, with increment of incrementllly 0 : pi/4 : pi Obtain non unit spacing, with increment of pi/4. result

Operators : Getting Started expressions + Addition - Subtraction * Multiplication / Division \ Left division (described in “Linear Algebra” in the MATLAB documentation) ^ Power ' Complex conjugate transpose ( ) Specify evaluation order

Arrays : Getting Started operators + Addition - Subtraction.* Element-by-element multiplication./ Element-by-element division.\ Element-by-element left division.^ Element-by-element power.' Unconjugated array transpose

Matrix : Getting Started Unit Multiplication e.g. a = [1 2 3; 4 5 6] b = [4 5 6; 7 8 9] Observe this: a*b …… results “Error” a.*b …… done the unit multiplication c = [1 2 3] c = c’ ………….. (transpose of matrix) Observe this: a*c b*c

Format function : Getting Started The format function controls the numeric format of the values displayed. e.g. x = [ 4/ e – 6 ] Type & Observe – format short format short e format short g format long format long e format long g format bank format rat format hex format compact

Command Line Editing : Getting Started KeyControl Key for MATLAB Standard Operation Up arrowCtrl + P Recall previous line. Works only at command line if you previously used the up arrow or Ctrl + P. Down arrowCtrl + NRecall next line. Works only at the prompt if you Left arrowCtrl + BMove back one character. Right arrowCtrl + FMove forward one character. Ctrl + Right arrow None Move right one word. Ctrl + Left arrow None Move left one word.

Command Line Editing : Getting Started KeyControl Key for MATLAB Standard Operation HomeCtrl + AMove to beginning of current statement. EndCtrl + EMove to end of current statement. NoneCtrl + HomeMove to top of Command Window. NoneCtrl + EndMove to end of Command Window. EscCtrl + UClear command line when cursor is at the prompt. Otherwise, move cursor to the prompt.

Command Line Editing : Getting Started KeyControl Key for MATLAB Standard Operation DeleteCtrl + DDelete character after cursor. BackspaceCtrl + HDelete character before cursor. NoneCtrl + KCut contents (kill) to end of command line. NoneShift + HomeSelect from cursor to beginning of statement. NoneShift + EndSelect from cursor to end of statement.

Command Line Editing : Getting Started KeyControl Key for MATLAB Standard Operation NoneCtrl + C or Ctrl + Break Stop execution of whatever is currently running, if feasible.

Practice : Getting Started Calculate and Observe : x 3 …………….(i) 1+2*3………..…..(ii) (1+2)*3 2. ……. ….1/2 + 3^2 + 4/5 * 6/7.……… 1/(2+3^2) + 4/5 * 6/7 Parentheses :

Practice : Getting Started

Practice : Getting Started

Basic 2D plot Getting Started Graphics Basic command for 2D plot plot ( xvalues, yvalues, ‘style option’ )

Basic 2D plot Getting Started Graphics Practice : %2D plot demo x = - 5 : 0.05 : 5; y = x.*cos (x.^2).*exp ( - x); plot (x, y) axis ( [ -5, 0, -600, 600 ] ) xlabel (‘X variable’); ylabel (‘function value y’); title (‘plot of y vs x’) legend ( ‘y-variation’ );

Basic 2D plot Getting Started Graphics Practice : %2D plot demo t=0:pi/20:2*pi; y=exp(sin(t)); plot (t, y) xlabel (‘X Axis’); ylabel (‘Plot Y Axis’); title (‘One y Axis’) %2D plot demo t=0:pi/20:2*pi; y=exp(sin(t)); plotyy (t,y,t,y, ‘plot’, ‘stem’) xlabel (‘X Axis’); ylabel (‘Plot Y Axis’); title (‘Two y Axis’) Type 1: Type 2:

Basic 2D plot Getting Started Graphics Practice : %2D plot demo x = 0 : pi/100 : 2*pi; y = sin (x); plot (x, y) xlabel (‘x = 0:2 \ pi’) ylabel (‘Sine of x’) title (‘Plot of Sine Function’, ‘FontSize’, 12)

Basic 2D plot Getting Started Graphics Practice : Multiple Data Sets in One Graph %2D plot demo x = 0 : pi/100 : 2*pi; y = sin (x); y2 = sin (x -.25); y3 = sin (x -.5); plot (x, y, x, y2, x, y3) legend (‘sin(x)’, ‘sin(x -.25)’, ‘sin(x -.5)’) xlabel (‘x = 0:2 \ pi’) ylabel (‘Sine of x’) title (‘Plot of Sine Function’, ‘FontSize’, 12)

Basic 2D plot Getting Started Graphics Practice : Specifying Line Style and Color in Graph %2D plot demo x = linspace (0,2*pi,100); figure (1) plot ( x, sin (x) ) xlabel (‘x’), ylabel (‘sin (x)’) title (‘Sine Plot’) grid on Contd…..

Basic 2D plot Getting Started Graphics Practice : Specifying Line Style and Color in Graph It is possible to specify color, line style and markers (such as plus sign or circle) when you plot your data using the plot command: plot ( x, y, ‘color_style_marker’) color_style_marker is a string containing from one to four characters (enclosed in a single quotation marks) constructed from a color, a line style and a marker type. The strings are composed of combinations of the following elements :

Basic 2D plot Getting Started Graphics Practice : Specifying Line and Marker Colors in Graph TypeValuesMeanings Color'c' 'm' 'y' 'r' 'g' 'b' 'w' 'k' cyan magenta yellow red green blue white black

Basic 2D plot Getting Started Graphics Practice : Specifying Line Styles in Graph Line style'-' '--' ':' '.-' no character solid dashed dotted dash-dot no line TypeValuesMeanings

Basic 2D plot Getting Started Graphics Practice : Specifying Marker types in Graph TypeValuesMeanings Marker type'+' 'o' '*' 'x' 's' 'd' '^' 'v' '>' '<' 'p' 'h' no character or none plus mark unfilled circle asterisk letter x filled square filled diamond filled upward triangle filled downward triangle filled right-pointing triangle filled left-pointing triangle filled pentagram filled hexagram no marker

Basic 2D plot Getting Started Graphics Practice : Specifying Line Style and Color in Graph Contd….. plot ( x, sin (x), ‘ks’) plot ( x, sin (x), ‘r’ ) plot ( x, sin (x), ‘r:+’) In above problem type this commands and observe :

Basic 2D plot Getting Started Graphics Adding plots in an Existing Graph The MATLAB hold command enables you to add plot to an existing graph, when you type : hold on Now MATLAB does not replace the existing graph when you issue another plotting command; it adds the new data to the current graph, rescaling the axis if necessary.

Basic 2D plot Getting Started Graphics Adding plots in an Existing Graph E.g. These statements first create a counter plot of the peaks function, then superimpose a pseudo color plot of the same function. [ x, y, z ] = peaks; pcolor ( x, y, z ) shading interp hold on contour ( x, y, z, 20, ‘k’ ) hold off The hold on command combines the pcolor plot with the counter plot in one figure.