You are on page 1of 4

# Lab 1:

Vector & Matrices: Two methods for defining vectors: 1. A=*1 2 3 4 5 6 7 8 9+ 2. A=1:1:9 /* 1 is starting no. and other 1 is the step size and the last 9 is the last no of vector*/

Can add, subtract, multiply, divide two vectors by a+b, a-b, a*b, a/b .
Functions: In matlab pre-defined functions are provided such as Sin, Cos, log, Sqrt, exp as well as many others, and many commonly used constants such as pi, i or j for the square root of -1 are also incorporated in matlab Matrices: Defining a matrix: 1st method is by entering semicolon(;) in vector: B=*1 2 3 4;5 6 7 8;9 10 11 12+ 2nd method is by hitting the enter key B= 1234 5678

## Enter Enter Enter

9 10 11 12

Matrices in MATLAB can be manipulated in many ways: Transpose: C=B' Multiply: 1. D=C*B 2. G=E.*F /*both matrices must be of same size*/ 3. For Cube : E.^3 Inverse: X=inv(E)

Eigen value of a matrix: eig(E) Polynomial: p=poly(E) Roots: roots(p) /* roots of polynomial*/

Lab 2:
Plotting: T=0:0.25:7; Y=sin(T); Plot(T,Y) Polynomial of : s4+1 Y=*1 0 0 0 1+ Multiplication of two polynomial: by using conv command X=*1 2+; Y=*1 4 8+; Z=conv(X,Y) Dividing two polynomial: by using deconv command *xx,R+=deconv(z,y)

Lab:3
Differentiation: using symbolic Math toolbox software so first create the symbolic expression: syms x F=sin(5*x) diff(f) Note: to take the derivative of a constant you must first define the constant as a symbolic expression For example: C= syms('5'); diff(C) if you just enter : diff(5) Matlab returns * + because 5 is not a symbolic expression

Symvar: If you do not specify a variable to differentiation with respect to, MATLAB chooses a default variable , the default variable is letter closer to x in alphabet. To determine the default variable that MATLAB differentiates with respect to use symvar command: symvar(f,1) Integration: If f is a symbolic expression then : Int(f) In contrast to differentiation, symbolic integration is more complicated task.

## Integration with real parameters : syms x a=sym(1/2); f=exp(-a*x^2); ezplot(f)

Lab 4:
Laplace Transform: Calculate the laplace F(s) transform of a function f(t) is simple in MATLAB. First specify the variables t and s as symbolic ones by using: >>syms t s Now define the function f(t) , the actual command to calculate the transform: >>F=laplace(f,t,s) Simplify : For simplified equation: >>simplify(F) Pretty: For pretty humanly written like equation: >>pretty(ans)

Inverse Laplace:

F=(s2
>>F=10*(s+2)/(s*(s^2+4*s+5)); >>ilaplace(F)

10(s-2) +4s+5)