20
By Tejas M. Kesarkar, M. Tech. TFE, [email protected] +917208548978

MATLAB Workshop - Part 1

Embed Size (px)

DESCRIPTION

matlab

Citation preview

  • By Tejas M. Kesarkar,

    M. Tech. TFE,

    [email protected]

    +917208548978

  • MATLAB Layout Command window (Enter commands directly, view output, give

    inputs)

    Workspace (Holds all the existing variables created by you while running a program)

  • Initializing variables v_name = XY will assign memory for a variable named

    Variable_name and the value of XY will be stored at that location

    d = zeros()

  • zeros function

  • Command window commands clc : clears command window

    clear v : frees the memory occupied by the variable v

    clear all : frees the memory occupied by all variables

    Ctrl + C : Terminate program while it is being executed

  • Math operations (+,-,/,*) + : addition

    - : subtraction

    / : division

    * : multiplication

  • Math operations (^,exp,log,log10) ^ : power

    exp : exponetial

    log : natural logarithm

    log10 : logarithm to the base 10

  • Trignometric functions sin(x) : sine

    cos(x) : cosine

    tan(x) : tangent

    csc(x) : cosecant

    sec(x) : secant

    cot(x) : cotangent

    asin(x) : sine inverse

    acos(x) : cosine inverse

    atan(x) : tangent inverse

    acsc(x) : cosecant inverse

    asec(x) : secant inverse

    acot(x) : cotangent inverse

  • Hyberbolic functions

    sinh(x) : hyperbolic sine

    cosh(x) : hyperbolic cosine

    tanh(x) : hyperbolic tangent

    csch(x) : hyperbolic cosecant

    sech(x) : hyperbolic secant

    coth(x) : hyperbolic cotangent

    asinh(x) : hyperbolic sine inverse

    acosh(x) : hyperbolic cosine inverse

    atanh(x) : hyperbolic tangent inverse

    acsch(x) : hyperbolic cosecant inverse

    asech(x) : hyperbolic secant inverse

    acoth(x) : hyperbolic cotangent inverse

  • Matrix algebra det() : determinant of a square matrix

    inv() : inverse of a non-singular square matrix

  • Matrix algebra Accessing elements of an array, X(i,j) : first index will

    denote the row number, second index will denote the column number

  • Matrix algebra Add, subtract, multiply matrices as simple variables

  • Creating programs using Editor format for saving of files ____.m

    Run programs using Run button

    Anything written on a line after % will not be executed

    disp() : Used for printing messages and values of variables

  • Creating programs using Editor input() : used to assign values of variables by user. For string type of

    inputs, enter string within single inverted commas fprintf(string,variable_names,) : Used to print strings Use \n for going to next line Use %d for integer type and %f for floating point type, %s for

    string type variables

  • remainder function rem(x,y) : returns the remainder after division of x by

    y

  • (a==b) : a is equal to b

    (a~=b) : a is not equal to b

    (ab) : a is greater than b

    (a=b) : a is greater than or equal to b

    Arguments need not be single variables. They can be expressions. E.g. (a

  • Conditional statements (if-elseif-else-end) if(condition 1)

    .statementsend

    if(condition 1).statements.else..statements.end

    if(condition 1).statementselseif(condition 1)statementsend

  • Conditional statements (switch-case-otherwise-end) switch expression

    case value_1.statements.case value_2.statements.

    end

    switch expressioncase value_1.statements.case value_2.statements.otherwise.statements.

    end

  • Using loops (for) for i = start_value : step_value : end_value

    statements to be repeated..

    end

    Note : Default step value is 1

  • while(condition)

    ..statements to be repeated..

    end

    Loop will be continuously executed until condition is proven to be false

    Using loops (while)