This action might not be possible to undo. Are you sure you want to continue?

BooksAudiobooksComicsSheet Music### Categories

### Categories

### Categories

### Publishers

Scribd Selects Books

Hand-picked favorites from

our editors

our editors

Scribd Selects Audiobooks

Hand-picked favorites from

our editors

our editors

Scribd Selects Comics

Hand-picked favorites from

our editors

our editors

Scribd Selects Sheet Music

Hand-picked favorites from

our editors

our editors

Top Books

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Audiobooks

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Comics

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Sheet Music

What's trending, bestsellers,

award-winners & more

award-winners & more

P. 1

control-1|Views: 3|Likes: 0

Published by api-19807868

See more

See less

https://www.scribd.com/doc/23355536/control-1

05/29/2014

text

original

What is MATLAB: The name Matlab is short for the MATrix LABoratory. It is commercial software package whose main function is to perform calculations on matrices, row vectors, and column vectors. It is widely used in both industry and academic institutions. It possesses many of the features of the High Level, numerically oriented programming language, but in addition has a large collection of built-in functions for performing matrix and vector operations in a way that is very simple for the user. In addition to functions for performing the usual computations from linear algebra (e.g., inverse, transpose, determinants etc.) Matlab has collection of toolboxes of more specialized functions for computations in specific areas of science and engineering including Control system Toolbox. 2. Entering and Quitting MATLAB. Start windows and double click on the MATLAB icon (if it is installed!). A command window will appear. You can write your programs directly on the window or you may open a new file from file menu, which appears on top of the command window. 3. Creating and Manipulating Matrices and Vectors. Matlab works on matrices and vectors that may be real or complex. Variables do not have to be declared (as in C-language). Computations are performed using doubleprecision arithmetic, and the results can be displayed in a variety of different formats. Let us enter a row matrix into the Matlab workspace. Type in:

» v=[2 4 7 5]

**and pressing enter key will result in echo back to you:
**

v = 2 4 7 5

this creates a variable v whose current value is a row vector with four elements as shown. To suppress the echo one uses semicolon following the command line. Thus

» W=[1 3 8 9];

creates another row vector W, but does not echo. To check that W has appeared in the Matlab workspace, type

» who

**which will display all the variables in the Matlab workspace as:
**

Your variables are: W » W v

**and to check the value of W simply type: and press enter key,
**

W = 1 3 8 9

Note that Matlab is case sensitive. EXERCISE-1: investigate the effect of the following commands: (i) (ii) (iii) (iv) (v) (vi) (vi) v(2) W(4) sum=v+W. diff=v-W vW=[v W] vW(2:6) v’

column vectors can be typed directly in one of two ways, for example, to enter the column vector 1 1 Z = 0 0 you can type

» Z=[1;1;0;0]or » Z=[1 1 0 0]

both will result in:

Z = 1 1 0 0

EXERCISE-2: investigate the effects of following commands: (i) (ii) (iii) (iv) (v) Z’ Z*v Z’*v’ [v;W] [Z;v’]

it creates a new matrix of single column combining the column vector Z and transpose of row matrix v. (vi) Z+v’ it simply adds the column vector Z with transpose of row vector v. These are various ways of entering matrices. For example, to enter the matrix 1 2 M = 3 4 the most obvious ways are to type

» M=[1 2;3 4] or » M=[1 2 3 4]

**but there are more perverse ways such as:
**

» M=[[1 3]'[2 4]']

EXERCISE-3: investigate the effect of the following commands: (i) (ii) (iii) (iv) N=inv(M) M*N det(M) I=eye(2) this creates a new matrix N whivh is a inverse of matrix M. it simply multiply M with N. it finds the determinant of matrix M. this display the identity matrix of order 2-by-2.

(v) (vi) (vii)

M+I M*Z v(3:4)*M

this add the Identity matrix with matrix M. it will multiply matrix M to first and second row of matrix Z. (viii) M(I,I) It will display first element (1x1) of the matrix. (ix) M (1:2,1:2) will display elements in(2x2) matrix. (x) M(:,1) will only display first column’s elements. (xi) M(2,:) it will only display the second row of the M matrix. 4.Built-in functions and Matlab HELP. You have already encountered some built-in functions. In addition to standard arithmetic operations such as “+” and “*”, you have met inv (M) that generates the inverse of matrix M, det(M) that generates determinant of M and eye(2) that generates the 2-by-2 Identity matrix. Matlab has a very large number of built-in functions. To see the list of those variables on your machine type

» help

To get information a specific function (“det” for example) type » help det DET Determinant. DET(X) is the determinant of the square matrix X. Use COND instead of DET to test for matrix singularity. See also COND. The help command is very useful. Most of the Matlab built-in functions have very descriptive names and are easily remembered or guessed.

EXERCISE-4: use the help command to find out about the following built-in functions and make your own sample examples (i) ones Solution:

ONES Ones array. ONES(N) is an N-by-N matrix of ones. ONES(M,N) or ONES([M,N]) is an M-by-N matrix of ones. ONES(M,N,P,...) or ONES([M N P ...]) is an M-by-N-by-P-by... array of ones. ONES(SIZE(A)) is the same size as A and all ones.

Example program:

» ones(3) ans = 1 1 1 1 1 1 1 1 1

(ii) zeros Solution:

ZEROS Zeros array. ZEROS(N) is an N-by-N matrix of zeros. ZEROS(M,N) or ZEROS([M,N]) is an M-by-N matrix of zeros. ZEROS(M,N,P,...) or ZEROS([M N P ...]) is an M-by-N-by-Pby-... array of zeros. ZEROS(SIZE(A)) is the same size as A and all zeros.

Example program:

» zeros(3) ans = 0 0 0 0 0 0 0 0 0

**(iii) linspace Solution:
**

» help linspace LINSPACE Linearly spaced vector. LINSPACE(x1, x2) generates a row vector of 100 linearly equally spaced points between x1 and x2. LINSPACE(x1, x2, N) generates N points between x1 and x2. See also LOGSPACE, :.

Example program:

» linspace(0,1) ans = Columns 1 through 7 0 0.0606 0.0101 0.0202 0.0303 0.0404 0.0505

(iv) logspace Solution:

LOGSPACE Logarithmically spaced vector. LOGSPACE(d1, d2) generates a row vector of 50 logarithmically equally spaced points between decades 10^d1 and 10^d2. d2 is pi, then the points are between 10^d1 and pi. LOGSPACE(d1, d2, N) generates N points. See also LINSPACE, :. If

Example program:

ans = Columns 1 through 7 1.0000 1.3257 1.0481 1.0985 1.1514 1.2068 1.2649

5.graphs The results of many control computations in Matlab are huge matrices containing, for example, frequency responses, that one would like to display in graphical form. We will plot graph of ys=sin(t) for t going from 0 to 5 seconds. First we need to generate a vector t containing the values of time that we want to use. Type:

» t=linspace(0,5,51)

which makes t into a row vector of 51 values from0 to 5 inclusive. Another way of doing same thing would be to type

» t=(0:0.1:5)

**both ways will result in:
**

t = Columns 1 through 7 0 0.6000 » plot(t,ys)

1 0 .8 0 .6 0 .4 0 .2 0 -0 . 2 -0 . 4 -0 . 6 -0 . 8 -1 0 0.5 1 1 .5 2 2 .5 3 3 .5 4 4.5 5

0.1000

0.2000

0.3000

0.4000

0.5000

**the graph can be prettied using thee following self explanatory sequence of commands:
**

» xlabel('time[in seconds]'); » ylabel('graph of sin(t)'); » title('2KES23');

2K E S 23 1 0.8 0.6 0.4 graph of sin(t) 0.2 0 -0 . 2 -0 . 4 -0 . 6 -0 . 8 -1

0

0.5

1

1.5

2 2.5 3 t im e [ in s e c o n d s ]

3.5

4

4.5

5

more than one set of points can be plotted on the same axes, and more than one graph can be displayed on the screen at once. EXERCISE-5 (i) Generate a vector containing the values of cos (t) for the same time range before. Solution:

» yc=cos(t) yc = Columns 1 through 7 1.0000 0.8776 » plot(t,yc)

1 0.8 0.6 0.4 0.2 0 -0 . 2 -0 . 4 -0 . 6 -0 . 8 -1

0.9950 0.8253

0.9801

0.9553

0.9211

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

(ii) From “help” entry for “plot” find out how to get both ys an yc plotted against t on the same axes. Solution:

**» t=(0:0.1:5); » ys=sin(t); » plot(t,ys) » hold on » plot(t,yc) » hold off
**

1 0 .8 0 .6 0 .4 0 .2 0 -0 . 2 -0 . 4 -0 . 6 -0 . 8 -1

0

0 .5

1

1 .5

2

2 .5

3

3 .5

4

4 .5

5

(iii) From the “help” entry for “subplot” find out how to plot ys and yc plotted on two separate graphs, one above the other. Solution:

» subplot(2,1,1),plot(t,ys) » subplot(2,1,2),plot(t,yc)

1 0.5 0 -0.5 -1

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

1 0.5 0 -0.5 -1

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

Optical_Fibre_Communications-senoir

optical devices

Light emitting diode

LED2

LED1

fiber_optic

Signals.and.systems.made.simple.Karu.2001.scan

War_and_Peace_NT

The_Thirty-Nine_Steps_NT

The_Red_Badge_of_Courage_NT

The_Portrait_of_a_Lady_NT

Paradise_Lost_NT

Nostromo_NT

love me little love me long

Beyond_Good_and_Evil_NT

SMS GSM HANDBOOK

scada procure

Microwave Engineering 3e - David M Pozar - Solutions Manual

Kluwer,.Wireless.Communications.Systems.and.Networks.(2004).YYePG

John.Wiley.&.Sons.WiMAX-Technology.for.Broadband.Wireless.Access.2007

Innovation on Medical Electronics

encf_7

Electronic Imaging Devices

economics

Digital Electronics

- Read and print without ads
- Download to keep your version
- Edit, email or read offline

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

CANCEL

OK

You've been reading!

NO, THANKS

OK

scribd

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->