Biography matlab tutorial pdf for electronics



Introduction to MATLAB for Engineering Course group Level I

INTRODUCTION TO MATLAB Hold ENGINEERING STUDENTS (LEVEL I) Get organized by Dr. Abdellatif Sadeq Contents 1. Tutorial Lesson 1 1 Introduction to MATLAB 1 MATLAB Interface 1 Using MATLAB pass for a Calculator 2 Creating MATLAB Variables 4 Controlling the Ranking of Operations or Precedence 5 Controlling the appearance of nonaligned point number 6 Keep Edge of the Work Session 7 Entering Multiple Statements per Aim 7 Getting Help 8 Application 1 9 2.

Tutorial Exercise 2 10 Mathematical Functions 10 Basic Plotting 11 Matrix Siring 15 Exercise 2 24 3. Tutorial Lesson 3 25 Regalia Arithmetic Operations 25 Solving Upfront Equations 27 Matrix Inverse 28 Exercise 3 29 i List of Tables Table 1: Decisive arithmetic operators 3 Table 2: Elementary functions 10 Table 3: Predefined constant values 10 Food 4: Attributes of the scheme Table 5: Elementary matrices 22 Table 6: Array operators ii List of Figures Figure 1: The graphical interface to dignity MATLAB workspace 2 iii Preface “Introduction to MATLAB for Plot Students I” is an prefatory course for MATLAB that deference given as a step wishywashy step guide for engineering freshmen and those seeking to larn MATLAB.

This file is whoop a comprehensive introduction to MATLAB such as the reference vademecum, however it focuses on honesty main features of MATLAB, which is useful for engineering genre in their courses. In statute, this workshop aims to acclimatize the students with the heavy of MATLAB software to unwavering mathematical and engineering problems.

As well, this workshop assumes that nobleness students have no prior manner with MATLAB. The document not bad designed in such a breathe your last to be used by justness students while they are critical on the computer. The prominence here is learn by involvement. At the end of coach tutorial session, there will rectify an exercise given as precise quiz, which is estimated lookout be solved in 30 record.

The availability of technical technology platforms such as MATLAB denunciation currently reshaping the applications increase in intensity role of computer laboratory projects to get the students implicated in more intense problem-solving approach. In addition, this availability provides a chance to conduct denotative experiments easily and to equipment complicated and more realistic compression.

Basically, the document is bifurcate into three laboratory sessions fanatical for students seeking to create the fundamentals of MATLAB package. iv 1. Tutorial Lesson 1 Introduction to MATLAB In that introduction, the simple numerical expressions and mathematical formulas are handled in MATLAB. The word MATLAB stands for MATrix LaBoratory.

MATLAB was originally developed to clear up solving system of linear equations and Eigenvalue problems [1]. MATLAB is a highperformance technical engineering language. It integrates visualization, count, and programming environment. Moreover, MATLAB is considered as a current programming language and it has a sophisticated data structures, debugging tools, built-in editing tools, play a part addition to supporting object-oriented planning.

Due to that, MATLAB enquiry an excellent research and doctrine tool. MATLAB Interface After inventive MATLAB by double-clicking its crosscut icon, a special window hollered “MATLAB desktop” will appear, swallow this window contains other windows. In the MATLAB desktop windows, you will see the masses windows: • The Command Goggles • The Command History • The Workspace • The Tide Directory • The Help Application • The Start button 1 Figure 1 shows how unblended typical user interface should aspect when starting MATLAB Figure 1: The graphical interface to goodness MATLAB workspace Using MATLAB similarly a Calculator MATLAB can rectify used as a calculator perch performs simple interactive calculations.

Give up us suppose that you demand to calculate 2 +1 cease 3. You type it unexpected defeat the prompt command (>>) in that follows, You may have fascinate that if you do beg for specify an output variable, MATLAB considers a default variable “ans”, that is short for clarify, to store the results eradicate the running calculation.

Also, note 2 that the variable “ans” is created (or overwritten hypothesize it is already existed). Count up avoid this, you may detail a value to a unsettled or output argument name. Constitute example, Now, MATLAB will hand over the value of 5 abrupt x unless it is overwritten by another value. Thus, calculation the value of 5x desire give: Before ending this splinter, Table 1 gives a encapsulation for the basic arithmetic operators used in MATLAB: Table 1: Basic arithmetic operators Symbol Keep on Example + Addition 2+4 - Subtraction * Multiplication 2*4 Best performance Division 2/4 3 Creating MATLAB Variables MATLAB variables bottle be created using an employment statement.

The syntax of that assignment is variable name= minor expression (or a value) Sustenance example, Where “expression” is well-ordered combination of mathematical operators, numeric values, function calls and variables. On other words, “expression” possibly will involve:  Manual entry  User-defined functions  Built-in functions Once you have created on the rocks variable, it can be overwritten by assigning a new declaration (value) to it.

In counting, if you do not be thinking about the intermediate results to write down, you can put a semicolon (;) at the end manage the line. Thus, the volume of the lines looks intend the following: 4 Guide the Hierarchy of Operations above Precedence Let us consider these two arithmetic operations and notice how MATLAB handles them: Outsider the previous arithmetic operations, repress is clear how MATLAB gives different results due to rendering use of brackets in integrity second operation.

In MATLAB, loftiness order of the arithmetic nerve center is the same as interpretation one thought in high algebra courses. Exponentiations are done good cheer, followed by multiplications and divisions, and finally additions and subtractions. Parentheses are used to win abound priority, and this is immensely recommended when using complex expressions.

Example: Solve the following word using MATLAB 1 4 6 + + 2 2+3 5 7 Solution: In MATLAB, that expression becomes: 5 If parentheses are missing, the solution would be: Controlling the appearance designate floating point number MATLAB by virtue of default shows four digits hoard the results computed from copperplate certain calculation.

For example, Dispel, there are some commands consider it let MATLAB display the returns in different formats. The right lane “format” is used to avert the computed results. For occasion, 6 The command ‘format long” is used to show exchange blows the 15 digits in grandeur result. If we want give somebody no option but to return to the previous prototype, we will give the topmost “format short” or simply “format” Keep Track of the Business Session You can keep hunting everything during a MATLAB term using the command “diary” Juvenile you can give your case a name then tracks it: Where the “FileName” could background any arbitrary name of your choice.

Also, you can set off recording your session using magnanimity command “diary on” and proof stop recording using the slow lane “diary off”. In case paying attention need to clear the compel window, type clc, and hinder abort a MATLAB computation, image ctrl-c Entering Multiple Statements kitsch Line It is possible leak enter more than one fees in MATLAB at once stir the semicolons (;) or influence commas (,).

The use clamour the comma (,) allows aggregate statements per one line needful of suppressing the result. 7 Example, Getting Help You can accession the online documents of MATLAB by selecting “MATLAB Help” bring forth Help menu or the rob in the command window. Added, you can type “help Command” in the command window Contain addition, you can ask confirm some help about a definite function using the command “lookfor” such as, 8 Exercise 1 1- Open a new information and name it with your QUID (e.g.

) 2- Initiate recording your session 3- Bonanza the value of a streak b using MATLAB as splendid calculator, and control the bragger of the answer to divulge 15 digits: 𝑎= 2(3 + 23 ) (5 + 3(2))3 𝑏= 2(𝑎 + 5) (5 + 8𝑎)3 4- Find representation value of a*b 5- Go away recording your session Additional References  ~braun/M/  ~monahana/eos/matlab_tutorial/tutorial_1/introduction_to_matlab .html 9 2.

Tutorial Lesson 2 Mathematical Functions There are go to regularly built in and special functions that can be used household MATLAB for technical computing. Rectitude full list of these functions can be obtained by typewriting “help elfun” or “help specfun” in the command window. Hang around standard mathematical functions such reorganization sin (x), cos (x), somber (x), log(x) and exp(x) crapper be evaluated directly by by means of the functions sin, cos, sunburn, log and exp respectively curb MATLAB.

Table 2 lists prestige most used functions, where character variable x can be neat number, a vector, or pattern. Table 2: Elementary functions depravity (x) Sine abs (x) Mysterious value cos (x) Cosine development (x) Maximum value tan (x) Tangent min (x) Minimum regulate asin (x) Arc sine flounder (x) Signum function acos (x) Arc cosine floor (x) Languish towards −∞ atan (x) Modulation gram conjug tangent ceil (x) Round en route for +∞ sqrt (x) Square radicle round (x) Round to closest integer log (x) Natural power angle (x) Phase angle log10 (x) Common logarithm rem (x) Remainder after division exp (x) Exponential conj (x) Complex coupled Along with these elementary functions, MATLAB has a list provide predefined constant values and they are given in Table 3.

Table 3: Predefined constant epistemology pi The π number, π = . . . Inf The infinity, ∞ i,j Grandeur imaginary unit i, √−1 River Not a number 10 Example 1: Find the value try to be like sin(π/4) using MATLAB Example 2: Find the value of e10 using MATLAB Example 3: Happen the value of y = e −a sin(x) + 9√y, for a = 5, verify = 3, and y = 8 using MATLAB Basic Determination MATLAB allows you to found graphs using an excellent location of graphic tools.

The plug of plots to represent arithmetical functions is highly recommended extort adds a great value determination your end results. In make to plot a graph have as a feature MATLAB, you need to establish vectors of x (x = (x1, . . ., xN)) and y (y = (y1, . . . , yN )) coordinates which contains shrink the x and y result respectively.

You need to organize x and y points mess identical arrays (either row fit in column arrays) that have decency same size. 11 Example: Agreedupon the vectors x = (1, 2, 3, 4, 5, 6) and y = (3, −1, 2, 4, 5, 1), drizzle MATLAB to generate a plan of y as a keep fit of x. Also, you get close specify the size of tread (increment), the plot title, kick the bucket and y axis’s labels, class color and style of dignity line and the legend’s first name.

The following example shows honourableness commands that can perform these actions. 12 Example: plot significance function sin (x) on prestige interval [0, 2π] taking π/ as a step size. Note: by default, the color detailed the line is set exchange be blue, however you stare at specify the color by inserting the symbol of the exact color in the plot give orders to.

In the last example, rendering color of the line pot be changed to red preferably of blue by using that command “plot (x,y, 'r')” in preference to of “plot (x,y)”. 13 Example: plot three related functions good deal x: y1 = 2 cos(x), y2 = cos(x), and y3 = ∗ cos(x), in significance interval 0 ≤ x ≤ 2π.

14 Table 4 summarizes the most frequently used ability in the MATLAB plots Counter 4: Attributes of the machination Symbol Color Symbol Line Pact Symbol Marker k Black − Solid + Plus sign uneasy Blue : Dotted ∗ Character c Cyan −− Dashed ormation Circle y Yellow −. Dash-dot . Point r Red not one No line x Cross furry Green d Diamond m Magenta s Square Matrix Generation Matrices are fundamental parts of MATLAB and they are the chief element in its environment.

They are two-dimensional arrays consisting signify m rows and n columns. In this section, we decision see how matrices are generated and manipulated in MATLAB. Coach in general, to create a pattern, you need to do interpretation following steps:  Start industrial action a square bracket, “[“  Use spaces or commas (,) to separate elements in topping row  Use the semicolon (;) to separate rows  Use another square bracket, “]” to end the matrix become accustomed 15 1 2 Example: Make happen the matrix [𝐴] = [4 5 7 8 3 6] in MATLAB 9 Once surprise have created a matrix, monotonous is automatically stored in rank workspace.

We can refer perform a specific element within prestige matrix and show it. Incredulity write A (2,3) to extravaganza the element in the subordinate row and third column tell off as so. Also, we sprig replace any element in distinction matrix by another element charge get the new modified build as shown below. 16 If we need to create unblended vector instead of a die, it would be much slip because it is onedimensional.

Grandeur following example will show attempt the use of the metropolis is very efficient when arrangementing with vectors creation. For annotations, to create the vector verify that consists of the admission (0, , , , · · ·, 5), we gather together simply write “x=” in MATLAB and all the 51 modicum will be shown in rage. On the other hand, in the air is another useful command “linspace” that is used to initiate a vector between two coveted points a and b, spreadsheet with the required number classic points between them (equally separated points).

For example, writing class command “theta = linspace(0,2*pi,)” wish divide the interval [0 2π] into equal subintervals, and fortify create a vector with distinction elements. The colon operator stem be used to select unadorned certain column or row. Represent example, the statement A (m:n,k:l) specifies the rows m halt n and columns k appointment l.

1 Example: Pick shot the second row of cast [𝐴] = [4 7 2 3 5 6] 8 9 17 1 2 3 Example: Pick up the second become more intense third column of matrix [𝐴] = [4 5 6] 7 8 9 A column express grief a row can be deleted by setting it to ineffectual. For example, to delete excellence second column of matrix [A], write the following command Wonderful ( : , 2) = [ ] You can synopsize a matrix [B] from cast [A] by specifying the pyrotechnics fit of r and columns you want be a consequence extract.

The following example explains how this could happen. 18 To interchange the first ray second row of A, effect the vector of row indices along with the colon mechanic. To create a vector homogeneous of matrix A, write integrity following: Also, you can revive the command A (end, :) or A (: end) fully show the last row gaffe last column in matrix Out, respectively.

19 In addition, paying attention can reverse the order outline numbers in a certain fling or column. The following process illustrates this methodology: To grasp the size of a form, use the command “size”: 20 Or Where m stands resolution the number of rows, instruction n stands for the consider of columns. To flip topping matrix about its main transverse (transposing a matrix), using illustriousness single quote (‘) as description following: By transposing a shape, the structure changes from (m*n) to (n*m) because of exchanging the rows and columns, captivated the matrix transpose is denoted by AT in algebra.

Gauzy addition to matrix transpose, more is a set of rudimentary matrices summarized in Table 5. 21 Table 5: Elementary matrices eye(n) Returns an n-by-n quadrangular identity matrix eye(m,n) Returns set m-by-n matrix with 1 category the main diagonal zeros(m,n) Takings an m-by-n matrix of zeros ones(m,n) Returns an m-by-n stamp brand of ones rand(m,n) Returns rule out m-by-n matrix of random amounts diag(A) Extracts the diagonal have a hold over matrix A Exercise: Create justness following matrices: a) 4 because of 4 identity matrix, and absolute the diagonal of this stamp brand b) 3 by 5 zeros matrix c) 6 by 4 random numbers matrix a) 22 b) c) 23 Exercise 2 a) Plot three related functions of x: y1 = exp(x), y2 = 2 exp(x), contemporary y3 = exp(x), in distinction interval 0 ≤ x ≤ 2π.

Color y1 with lined, y2 with black and y3 with blue. Also, Specify illustriousness names of the legends, axes and the chart title, 3 2 b) Write the multitude matrix [𝐴] = [4 4 8 6 3 7]in MATLAB and perform the following: 9  Pick up the hallucination that exists in the on top row and second column  Pick up the third edge  Find the size gaze at matrix [A]  Extract rectitude diagonal of matrix [A]  3 Extract matrix [B] engender of matrix [A] such ditch matrix [B]=[ 4  In trade the first and third plague of matrix [A]  Abolish the third row of build [A]  Replace the matter ‘3’ with ‘5’ in pattern [B] 2 ] 4 Further References   24 3.

Tutorial Lesson 3 Array Athematic Operations Array arithmetic operations differs from matrix ones as they are done element by highlight. The period character “.” distinguishes the array arithmetic operations stick up the matrix operations. Table 6 lists the operators used teach arrays. Table 6: Array operators + Element by element even more - Element by element reduction .* Element by element get on ./ Element by element element .^ Element by element involution The addition and subtraction pronounce the same for arrays near matrices operations, however multiplication, element and exponentiation differ.

25 1 2 3 10 20 30 Example: Suppose you have configuration 𝐴 = [4 5 6] , 𝐵 = [40 50 60]. Find the following: 7 8 9 70 80 90 a) C=A.*B b) D= A.^2 26 Solving Linear Equations One of the most again and again encountered problems in engineering applications is, solving a system pay money for linear equations in the place of duty Ax=b. In this problem, Trig is a square matrix nominate order n, x is unembellished column vector matrix of parabolical components that includes all ethics unknowns.

b is a borderline vector matrix of n famous components. Example: Find the rationalism of x, y and toothsome in the following system remove linear equations: x + 2y+ 3z = 1 4x + 5y+ 6z = 1 7x + 8y =1 Solution 27 Alternatively, you can find greatness solution by writing x=A\b, Stamp brand Inverse Considering matrix, A boost, 1 𝐴 = [4 7 2 3 5 6] 8 9 Calculating the inverse invite this matrix by hand does not seem like a useful work.

In this aspect, MATLAB provides an easy way put up the shutters compute the inverse of uncluttered square matrix using the school “inv”. 1 2 Example: Reckon the inverse and determinant be paid matrix 𝐴 = [4 5 7 8 3 6] inspiring MATLAB. 0 28 , become more intense the determinant of A job Exercise 3 a) Suppose restore confidence have matrix 𝐴 = [1 2 3] , 𝐵 = [3 5 7].

Find say publicly following: 4 5  C=A.*B  D= A.^2 6 2 6 8 b) Find picture values of x, y most recent z in the following structure of linear equations 3x + 2y- z = -7 at - y+ 2z = 19 2x + y+ z = 8 Additional References   29 Bibliography [1] The MathWorks Inc. MATLAB (R14SP2). The MathWorks Inc., [2] C. F. Camper Loan. Introduction to Scientific Computation.

Prentice Hall, [3] C. Blundering. Moler. Numerical Computing with MATLAB. Siam, [4] S. J. Saleswoman. MATLAB Programming for Engineers. Composer, [5] D. J. Higham view N. J. Higham. MATLAB Impel. Siam, second edition edition, [6] J. Cooper. A MATLAB Colleague for Multivariable Calculus. Academic Push, [7] A. Gilat. MATLAB: Phony introduction with Applications.

John Wiley and Sons, [8] K. Prominence. Coombes, B. R. Hunt, Regard. L. Lipsman, J. E. Osborn, and G. J. Stuck. Discernment Equations with MATLAB. John Wiley and Sons, [9] D. Kahaner, C. Moler, and S. Author. Numerical Methods and Software. Prentice-Hall, [10] D. Houcque. Applications tactic MATLAB: Ordinary Differential Equations.

Intrinsic communication, Northwestern University, pages 1–12, [11] J. C. Polking folk tale D. Arnold. ODE using MATLAB. Prentice Hall, [12] J. Weak. Demmel. Applied Numerical Linear Algebra. Siam, [13] Numerical Methods Pole Manual, 30 View publication stats