20 views

Uploaded by Ghulam Abbass

FCS

- Wavelet Families and Properties - MATLAB & Simulink - MathWorks India
- Matlab Tutorial Umich
- Introduction to Matlab.ppt
- C Programming Lab Manual
- baru
- Matrix Chain Multiplication
- ANSYS® Customization and Automation With APDL
- EMPR
- MATLAB (1)
- Notes on MATLAB Programming
- Kruger, Westermann - Linear Algebra Operators for GPU Implementation of Numerical Algorithms
- Matlab
- SystemofSprings (2)
- Bard and the Bible
- matlab instalacion
- 2016 Syllabus 12 Mathematics
- Matlab Programming Assignment 2014 Civil Engineering
- Introduction Tom at Lab
- 1-s2.0-095183399290014G-main
- Labview Tutorials 01

You are on page 1of 10

Objectives: The objectives of these notes are to give a brief general introduction to MATLAB and to familiarize you with the most commonly used functions. The notes contain exercises that you should try out as you go along and are intended to be reasonably self-contained. However the MATLAB manuals contain tutorial introductions and there are built-in demonstrations and tutorial material in the MATLAB software itself. To become familiar with MATLAB Declaring matrices in MATLAB command window. Performing various matrix operations, to manipulate them. Basic plotting techniques

Theory: What is MATLAB? The name MATLAB is short for MATrix LABoratory. It is a 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 a high level, numerically oriented programming language, and it has a large collection of built-in functions for performing matrix and vector operations in a way that is very simple for the user. For example, to find the determinant of a matrix A one needs only enter: det(A). MATLAB commands can be entered one line at a time, or the user can write programs of MATLAB code and define his/her own functions. In this session, we shall only use the one-line-at-a-time interpretive mode for simplicity, but the regular user will find that the power of the package is considerably extended by writing his/her own programs and functions.

Use Of Matlab In Control Engineering Its a very powerful tool used in control system designing. User can develop its own applications, can find the desired Transfer Function, simulate and analyze the result, check out various possibilities for multiple inputs, can work in frequency and time domain, develop your own block diagrams etc. Simulink library gives a huge range of defined blocks for creating applications without writing codes.

Entering and quitting MATLAB To enter MATLAB, simply double click on the MATLAB icon. To leave MATLAB and return to the PCs operating system simply type: quit

Creating and manipulating matrices and vectors MATLAB works on matrices and vectors that may be real or complex. Results can be displayed in a variety of different formats. Let us enter a row vector into the MATLAB workspace. Type in: v = [2 4 7 5]

This creates a variable v whose current value is a row vector with four elements as shown. After pressing return the value of v will be echoed back to you. To suppress the echo, one uses a 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, and to check the value of w simply type w. Operations on row vectors can be best illustrated by some simple exercises. Column vectors can be typed in directly in one of two ways. For example, to enter the command vector

1 1 z 0 0

or

z = [1 1 0 0];

One way of creating matrices is by multiplying row and column vectors. There are various ways of entering matrices. For example, to enter the matrix

1 2 M 3 4

3 4]; but there are more complex ways such as M = [[1 3][2 4]];

Operators Used In MATLAB Point operator: point operator is used for element-by-element calculations e.g. C = A.*A D = A./B It will multiply corresponding elements of A with A. It will divide corresponding elements of A by B.

Transpose: It converts column vector into row vector and vice versa e.g. A= B= B= [1 2 3 4] A 1 2 3 4 is a row vector B equals to the transpose of A. B is a column vector.

Semicolon: o If used inside an array, semicolon terminates the corresponding line operation and shifts the cursor to the next line without executing it i.e. it breaks up a row and shifts the next element to the next line or row e.g.

3

o If used after an array, semicolon suppresses the echo of vectors and matrices when ENTER is pressed. Parenthesis: ( ) are used to execute any function you specify e.g. eye(2) Arithmetic Operators: Arithmetic operators perform numeric computations, for example, adding two numbers or raising the elements of an array to a given power. The following table provides a summary. Operator + .* ./ .\ .^ * / \ ^ Description Addition Subtraction Multiplication Right division Left division Power Matrix multiplication Matrix right division Matrix left division Matrix power

Relational Operators: Relational operators compare operands quantitatively, using operators like "less than" and "not equal to." The following table provides a summary. Operator < <= > >= Description Less than Less than or equal to Greater than Greater than or equal to

4

Operator == ~=

Logical Operators: The symbols &, |, and ~ are the logical array operators AND, OR, and NOT. These operators are commonly used in conditional statements, such as if and while, to determine whether or not to execute a particular block of code. Logical operations return a logical array with elements set to 1 (true) or 0 (false), as appropriate. These are shown in the table below. Logical Operation A&B A|B ~A Equivalent Function and(A, B) or(A, B) not(A)

Colon: o Creates a list of numbers e.g. A=0:5 A=0 1 2 3 4 5 o Works with all the entries in specified dimensions e.g. Q = [1 2 ; 3 4]; R = Q(: , 2) R=3 4

Built-in Functions and MATLAB help MATLAB has a very large number of built-in functions. To see the full list of those variables on your machine type help To get information on a specific function (inv for example) type help inv The help command is very useful. Most of the MATLAB built-in functions have very descriptive names and are easily remembered or guessed. Some of them are: clear clc trigonometric functions zeros and ones

5

Basic Plotting Commands and Codes: Continuous Time Plots: Plot command: PLOT command is used to plot continuous tome signal defined in time domain as shown in figure. Plot(t,y) where y is desired function and t is time. Subplot: It is used to display 2 or more graphical function on the same graph with two different plots as shown in the figure. Example: subplot(2,1,1) 2 shows number of rows a figure window is broken up into. 1 shows number of columns a figure window is broken up into. Last 1 shows, out of 2 functions 1st function is plotted first. (Note: Use plot command first) subplot(2,1,2)

Multiple functions on same plot: to plot two or more function simultaneously on one graph use the following code Plot (t,function1, t,function2) Plot(t,y1,t,y2) Plot(t,y1,o,t,y2,*)

Plotting with symbols: To plot certain distinct values on the continuous graph use the following code. Plot(t,y,*) Graph along function and distinct points are plotted

Discrete Plots: Stem Command: STEM command to plot discrete time signals. Define n vector rather t. Modifying Your Graph: AXIS Command: Define x and y axis and give range for x and y axis axis ([x1 x2 y1 y2]) X-LABEL Command: It gives x-axis appropriate label xlabel(time in seconds) Y-LABEL Command: It gives x-axis appropriate label ylabel(particular function) TITLE: It gives suitable title to your graph. title(Electronics) TEXT: It adds text on the desired position (row and column) on the graph. text (a, b,Electronics Engineering) text (1.3,2.1,Electronics Engineering) Where a and b are row and column positions

7

Legend: legend(string1, string2 , string3 , ...) puts a legend on the current plot using the specified strings as labels. HOLD ON: hold on holds the current plot and all axis properties so that subsequent graphing commands add to the existing graph. hold on sets the Next Plot property of the current figure and axes to "add".

Program to plot a graph The results of signal processing computations in MATLAB are huge matrices containing, for example, frequency responses, which one would like to display in graphical form. We will go through a simple example of generating data, plotting the graph, putting labels on the axes etc. We will plot the graph of y = sin(t); for t going from 0 to 20 seconds. First we need to generate a vector t containing the values of time that we want to use. Type: t=linspace(0,20,100); which makes t into a row vector of 100 values from 0 to 20 inclusive. Then type ys = sin(t); To plot the set of points type: Plot(t,ys) The basic graph can be prettied up using the following self explanatory sequence of commands: xlabel(Time in seconds) ylabel(sin(t)) title(your Roll No.) grid Explore: whos, who, pwd, hold, sqrt, exp function and M-file. (Attach their answers in the handouts).

Exercise: You are required to perform them on MATLAB and copy those to word and attach printouts.

1. Investigate the effect of the following command and explain operation/function: a. v(2) b. sum = v + w c. diff = v w d. vw = [v w] e. vw(2: 6) f. v g. z h. z*v i. [v; w] j. v*z k. [z; v] l. z + v m. M(1,1) n. M(1:2,1:2) o. M(:,1) p. M(2,:) q. M(:,end) r. M(:,end-1) s. M(:,[1 3]) t. M(:,:) u. M(:,2)=[] v. fliplr(M) w. flipud(M) x. M(:) convert matrix column vector y. M=M(:) convert matrix to row vector 2. Apply DIAG function to vector v and matrix M mentioned in exercise#1. Explain the results 3. Generate a row vector a=1:5; Investigate the following commands and explain: i. a(2)=6; ii. a([ 1 3])=0 iii. a(1,2)=100 iv. a(3)=[ ] v. a([1 4])=[]

4. Write a matlab code to plot following functions( attach graphs). Also provide axes and labels to graphs Use t=1:0.01:10 (i) cos (pi*t) (ii) sin(t) (iii) (iii) cos(t) (iv) (iv) cosec(2*pi*t) 5. Repeat problem 4 using subplot and legend commands for plotting the given functions. 6. Repeat problem 4 using the commands plot(t,y1,t,y2..) and legend. (NOTE: Write your roll number , xlabel, ylabel on each graph. 7. Differentiate Linspace(1,10) and logspace(1,10) . 8. How can you save a program in MATLAB. What is the advantage of writing a program in M-file and if any error occurs in M-file how can you check that error. What role command window plays here? Observation: Attach the prints of the plots you obtain in the exercises above.

10

- Wavelet Families and Properties - MATLAB & Simulink - MathWorks IndiaUploaded byAtul Mani
- Matlab Tutorial UmichUploaded byNandita Abhyankar
- Introduction to Matlab.pptUploaded byJithendra Nath
- C Programming Lab ManualUploaded bySiva Kiran
- baruUploaded byNorazimah Mat Zain
- Matrix Chain MultiplicationUploaded byAghosh Babu
- ANSYS® Customization and Automation With APDLUploaded byasextos
- EMPRUploaded byKenny Wei Chih Chen
- MATLAB (1)Uploaded byKartik Dutta
- Notes on MATLAB ProgrammingUploaded byrikeshsemail
- Kruger, Westermann - Linear Algebra Operators for GPU Implementation of Numerical AlgorithmsUploaded byErnesto Varela
- MatlabUploaded byRoberto Hernández
- SystemofSprings (2)Uploaded bysksiddique
- Bard and the BibleUploaded byJoe Mckay
- matlab instalacionUploaded bychgamboa
- 2016 Syllabus 12 MathematicsUploaded bydevender
- Matlab Programming Assignment 2014 Civil EngineeringUploaded byPayel Dutta
- Introduction Tom at LabUploaded byamitaiisc
- 1-s2.0-095183399290014G-mainUploaded byParthipan Jayaram
- Labview Tutorials 01Uploaded bySbo
- Matrix Cheatsheet TableUploaded byLan Ngo
- Pivot-Free Block Matrix Inversion.pdfUploaded bylepijoni
- Model Use GuidanceUploaded byKarthi Kumar
- bs lab.docUploaded byVenky Venkatesh
- Java Program PracticalUploaded bymaladeep
- lab1Uploaded byAnonymous DXhLqT
- Ner LoveUploaded byvjjani2204
- Linear_Algebra_for_Deep_Learning.pdfUploaded byzentropia
- sect8_3Uploaded byjrmaurinho
- CompUploaded byAnuj Batham

- Financial ManagementUploaded byGhulam Abbass
- trans1Uploaded bySanthosh Katkuri
- Lab 01 RelayUploaded byGhulam Abbass
- ee1002.pdfUploaded bybedilu77
- Convex Amp LesUploaded bykika12345
- eceb211Uploaded byGhulam Abbass
- I&M AoL CourseOutliesUploaded byGhulam Abbass
- EE305LabFoy.pdfUploaded bySusanta Kumar Rout
- Physical Examination Form (2)Uploaded byGhulam Abbass
- Presentation ThesisUploaded byGhulam Abbass
- lecture1423813026.pdfUploaded byKarthikeyanKarun
- Pl Chapter 07Uploaded byGhulam Abbass
- PLCHAPTER07.pptUploaded byGhulam Abbass
- Siemens LadderUploaded byrph3
- S7-1200 manualUploaded byKongkeat Suwantawee
- ADC ContentsUploaded byGhulam Abbass
- CertificateUploaded byGhulam Abbass
- JK FFUploaded byGhulam Abbass
- Basic English VocabUploaded byGhulam Abbass
- Digital Communication LabManual.pdfUploaded bynedumaran
- Basic Config Using Cisco IOS Command Line InterfaceUploaded byMarco Aurelio Martinez Jimenez
- Intro to MatlabUploaded bykesavanp
- Experiments With Matlab BookUploaded byosencan
- 71321Uploaded byGhulam Abbass
- Professors DataUploaded byGhulam Abbass
- Computer Hardware PptUploaded byraj0070095
- CTE I Computer PartsUploaded byGhulam Abbass

- 319057998 Syllabus Matdip301 Matdip401 PDFUploaded byKrishna Krish
- Why is Division Multiplication by the Reciprocal?Uploaded bydgweaver
- Sadler-Specialist Mathematics-Unit 3A-Chapter 1-SolutionsUploaded byRolou15
- 9709_m17_qp_12 AS LEVEL MATHEMATICSUploaded bycharlene
- 463Uploaded byAliBaranIşık
- RreseUploaded byAbhinandan Dubey
- vectorUploaded byAbraham Gm
- SSM ET Chapter 12Uploaded byDustin Hagen
- AlgebraUploaded bySuhas Mahesh
- AP Calculus resource GuideUploaded byscribddownloaded
- Simon and BlumeUploaded bygottsstr
- quad projectUploaded byapi-315591662
- Stability in control systemsUploaded bysamir
- Sample Linear Algebra ExamsUploaded bysomeone
- test your paraphrasing skills worksheetUploaded byapi-298262474
- Tutorial 1 AnswerUploaded bySalim Bin Agil
- review essential skills and knowledgeUploaded byapi-235812883
- ch10-2Uploaded byblogs414
- [a. a. Kirillov] Elements of the Theory of RepreseUploaded bywillmate
- Mathematics+Results+SummaryUploaded byGreenBean1013
- ME2142E Feedback Control Systems-CheatsheetUploaded byPhyo Wai Aung
- John Bay-Fundamentals of Linear State Space Systems-McGraw-Hill _1998Uploaded byRoohullah khan
- Math 125 - HW 6 SolutionsUploaded byPhuc Dang
- PCA InterpretationUploaded byPrachi Jain
- ComE 312 Unit 1Uploaded byRhea Ann
- Algebra 2 Unit 2 CK12 Flexbook LinksUploaded byYiannis Papagiannopoulos
- hw2Uploaded byYehh
- Shankar - QM CookbookUploaded bybdefelis
- BME 332_ StressUploaded byselva_raj215414
- simplex methodUploaded byTamrika Tyagi