You are on page 1of 8

LAB No.

2:
To understand the method of a. Defining a matrix in MATLAB. b. Linear algebra in MATLAB. c. Creating M-file in MATLAB. d. Plotting graph in MATLAB.

Defining a matrix in MATLAB.


For defining matrix in matlab we use the command Command in matlab:
a=[3,6,45,91,47;8,72,5,53,8;54,2,90,34,56;65,4,81,38,5;48,6,10,53,100;]

the output in command window will be

a = 3 8 54 65 48 6 72 2 4 6 45 5 90 81 10 91 53 34 38 53 47 8 56 5 100

Linear algebra in MATLAB.


a) Determinant of a matrix: Command in matlab:
det=det(a)

the output in command window will be det = -1.9055e+009 b) Inverse of matrix: Command in matlab:
in=inv(a)

the output in command window will be in = -0.0088 -0.0009 -0.0143 -0.0075 0.0149 0.0103 0.0021 0.0006 0.0174 0.0116 -0.0013 -0.0153 -0.0017 0.0002 0.0126 c) Transpose of matrix: 0.0195 -0.0078 -0.0069 0.0104 -0.0137 0.0113 -0.0030 -0.0104 0.0027 0.0044

Command in matlab:
tr=a'

the output in command window will be tr = 3 8 6 72 45 5 91 53 47 8 54 2 90 34 56 65 48 4 6 81 10 38 53 5 100

Creating M-file in MATLAB.

Plotting graph in MATLAB.


Let us consider a simple sine wave whose graph has to be plot Command in matlab:
t=0:0.01:10 s=sin(t) plot(t,s) xlabel('time') ylabel('sine wave')

title('PLOTING GRAPH IN MATLAB')

Graph of signal in matlab:


PLOTING GRAPH IN MATLAB 1 0.8 0.6 0.4
sine wave

0.2 0 -0.2 -0.4 -0.6 -0.8 -1

5 time

10

Lab tasks
1. Prove EULERS formula both by mathematically and graphically using MATLAB:
GRAPHICALLY: Command in matlab t=0:0.01:10 a=cos(t)+(i*sin(t)) subplot(1,2,1) plot(t,a) xlabel('time t') ylabel('Cost+iSint') b=exp(i*t) subplot(1,2,2) plot(t,b) xlabel('time t') ylabel('e^i^t')

1 0.8 0.6 0.4 0.2 0 -0.2 -0.4 -0.6 -0.8 -1

1 0.8 0.6 0.4 0.2

Cost+iSint

eit
0 5 time t 10

0 -0.2 -0.4 -0.6 -0.8 -1

5 time t

10

MATHEMATICALLY: As the eulers formula is

Assuming the power of

i:

Taking R.H.S

2. Show graphically in MATLAB the effect of signal by increasing power:

Let we have a signal x(t) its power is

where,

Let us consider x(t)=cos(t) GRAPH OF x(t):

signal with power P 0 1 0.8 0.6 0.4 0.2


x(t)

0 -0.2 -0.4 -0.6 -0.8 -1

5 time t

10

If we increases the power 4 times i.e

By equation:

By comparing we get

As, x(t)=cos(t)

GRAPH OF

signal with power P 1 2 1.5 1 0.5

x (t)

0 -0.5 -1 -1.5 -2

5 time t

10

If we increases the power 9 times i.e

By equation:

By comparing we get

As,

x(t)=cos(t)

GRAPH OF

:
signal with power P 2 3

x (t)

-1

-2

-3

5 time t

10

CONCLUSION: From the analysis of the above signal we concluded that: Graphically it is clear that

If we increases the power of the signal If,

times its amplitude increases by n times.

Then,

You might also like