ppt day1 final

Upload: rabinsa-yadav

Post on 05-Apr-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Ppt Day1 Final

    1/27

    Department of Electrical Engineering

    Indian Institute of Technology Kanpur (IIT K)

    Abhishek Kr Gupta

  • 7/31/2019 Ppt Day1 Final

    2/27

    To MATLAB

  • 7/31/2019 Ppt Day1 Final

    3/27

    What is MATLAB? MATrix LABoratory

    Does Matrix Operations

    Thousands of inbuilt functions ToolBoxes

    GUIS

    A programming Language

    A complete software package Simulink Modeling tools

    EDA tools

  • 7/31/2019 Ppt Day1 Final

    4/27

    LAYOUT

  • 7/31/2019 Ppt Day1 Final

    5/27

    A Simple Start:Add two Variables

    No definitions needed, no classes needed

    On command window type:

    Type C to see the value

    C=9

    >>A=5;>>B=4;>>C=A+B;

  • 7/31/2019 Ppt Day1 Final

    6/27

    Editors: Editors are used to store codes

    Code is nothing but just a set of lines

    M Files are used in MATLAB having extension .m Types:

    Script File

    Set of code lines

    Function File A code implementing some functions like sin, cos exp (they

    are inbuilt)

  • 7/31/2019 Ppt Day1 Final

    7/27

    Defining Matrices:Just write all the entries separated by the space or

    comma and enclosed in a bracket []

    A=[1 2 3 2]Or

    A=[1,2,3,2]

    For column matrix, put semicolon ; in between

    A=[1;2;3;2]

  • 7/31/2019 Ppt Day1 Final

    8/27

    Importance of Matrix: Not just as a transformation

    Also set of data or samples

    Electrical Signals Performance outputs

    Images

    Also as model representation

    Polynomials Transfer functions

    Neural Networks

  • 7/31/2019 Ppt Day1 Final

    9/27

    Polynomials:

    These are some of thePolynomials you haveCome across.

  • 7/31/2019 Ppt Day1 Final

    10/27

    Polynomials in MATLABA polynomial can be represented in the form of

    coefficients. For example, if you want to write

    You have to just write [1 2 2 5]

    Each number represents the value of coefficients.

    This will be represented as [1 0 2 5]

  • 7/31/2019 Ppt Day1 Final

    11/27

    System Modeling using Matrix:

    Recall the well known example of LCR circuit:

    Output across resistor V0=R.i

    Modeled using matrix as

    I

    NPUT

    O

    UTPUT

  • 7/31/2019 Ppt Day1 Final

    12/27

    Similarly a Motor SystemA Motor Speed System

    We write its state equations:

  • 7/31/2019 Ppt Day1 Final

    13/27

    Transfer Functions

    Polynomials

    [K2]

    [1 2 K2]

  • 7/31/2019 Ppt Day1 Final

    14/27

    Neural Systems Systems modeled as a set of transformation with

    neurons as Weight matrixes

  • 7/31/2019 Ppt Day1 Final

    15/27

  • 7/31/2019 Ppt Day1 Final

    16/27

    Problems with Other Programming

    Languages No Matrix operations

    For Loops everywhere

    Lots of unnecessary lines

  • 7/31/2019 Ppt Day1 Final

    17/27

  • 7/31/2019 Ppt Day1 Final

    18/27

  • 7/31/2019 Ppt Day1 Final

    19/27

    with MALTAB

  • 7/31/2019 Ppt Day1 Final

    20/27

    Define Matrixs Mix , and ; to make 2 D matrix

    A=[1 2 3 2; 1 3 2 1;2 3 6 1]

    Make A 1 to 10 MatrixA=[1 2 3 4 5 6 7 8 9 10];

    Make 1 to 100

    Tired??

    Use colon :Which mean TO

    A=[1:100];

  • 7/31/2019 Ppt Day1 Final

    21/27

    Colon (:) = TO[1:4] Gives a vector from 1 to 4

    1 2 3 4

    [1:0.5:4]

    Gives a vector from 1 to 4 with step 0.5

    1 1.5 2 2.5 3 3.5 4

    [0:0.1:2*pi]

    Gives a vector containing 0 to 2

  • 7/31/2019 Ppt Day1 Final

    22/27

    Operators Matrix Operators

    Y=A^2

    Y=A^B

    X=A*B

    Dot Operators

    Y=A.^2 X=A.*B

    Y=A.^B

  • 7/31/2019 Ppt Day1 Final

    23/27

    Functions

    Subscripting

  • 7/31/2019 Ppt Day1 Final

    24/27

    Typical MATLAB functions Mathematical

    sqrt sin,cos,tan

    Log, exp Creation

    ones zeros eye

    Rand Information

    size length

  • 7/31/2019 Ppt Day1 Final

    25/27

    Typical MATLAB functions Matrix Operations

    sum diag

    transpose or inv det eig fliplr

    reshape flipud rot90 repmat

  • 7/31/2019 Ppt Day1 Final

    26/27

    Concatenation of Matrices Suppose A, B, C are matrices

    If we write [A B] or [A,B]

    If we write [A;B] Similarly [A B C] and [A;B;C]

    [[A B];C]

  • 7/31/2019 Ppt Day1 Final

    27/27

    Crete a with size 4x5

    With elements from 3to7\

    uGP