### Essential Matlab for Engineers and Scientists, Fourth Edition

Free download.
Book file PDF easily for everyone and every device.
You can download and read online Essential Matlab for Engineers and Scientists, Fourth Edition file PDF Book only if you are registered here.
And also you can download or read online all Book PDF file that related with Essential Matlab for Engineers and Scientists, Fourth Edition book.
Happy reading Essential Matlab for Engineers and Scientists, Fourth Edition Bookeveryone.
Download file Free Book PDF Essential Matlab for Engineers and Scientists, Fourth Edition at Complete PDF Library.
This Book have some digital formats such us :paperbook, ebook, kindle, epub, fb2 and another formats.
Here is The CompletePDF Book Library.
It's free to register here to get Book file PDF Essential Matlab for Engineers and Scientists, Fourth Edition Pocket Guide.

Published March 1st by Butterworth-Heinemann first published More Details Original Title. Other Editions Friend Reviews. To see what your friends thought of this book, please sign up. Lists with This Book. This book is not yet featured on Listopia. Community Reviews. Showing Rating details. More filters. Sort order.

Jul 30, Chris Lynch added it. A good solid book by well-qualified authors, that eases the user into exploring the capabilities of MATLAB in a friendly, chatty style - with only a couple of typographic errors to keep you on your toes! Aug 07, Navid Aliakbarian rated it it was amazing. Practical book for students. Jan 21, Dwight Walker rated it really liked it Shelves: engineering , manual , mathetmatics , matlab , problem-solving , programming , science , problem , solving. Tj Murphy rated it it was amazing Nov 22, Sabrina Soong rated it liked it Dec 31, Todd Albert rated it liked it Dec 03, This is a required step to gain confidence in any tool and in our ability to use it.

Commands are only carried out when you enter them. The answer in this case is, of course, 5. Yes, they are multiplication, division and exponentiation. The backslash means the denominator is to the left of the symbol and the numerator is to the right; the result for the last command is 5.

An explanation for the need for these symbols is provided later when we deal with arrays of numbers. This helpful feature is called command-line editing. You can select and edit commands you have entered using Up-arrow and Down-arrow. Remember to press Enter to have the command carried out i.

Just type the first few characters of the command you want to recall. Try it. Another special value that you may meet is NaN, which stands for Not-aNumber. Now we will assign values to variables to do arithmetic operations with the variables. This statement assigns the value of 2 to it.

Note that this value is displayed immediately after the statement is executed. Do you agree with the final value of a? Do we agree that it is 90? Now see if you can assign the sum of x and y to a third variable z in a single statement. Notice that, in addition to doing the arithmetic with variables with assigned values, several commands separated by semicolons or commas can be put on one line. See Appendix B. The answer should be 1. Because of the numerous built-in functions like pi or sin, care must be taken in the naming of user-defined variables.

Names should not duplicate those of built-in functions without good reason. In other words, if you decide to redefine a built-in function or command, the new value is used! The command whos is executed to determine the list of local variables or commands presently in the workspace. Try date and calendar for starters. It also has numerous commands, such as clc for clear command window. The difference between functions and. MATLAB also handles vectors generally referred to as arrays , which are the key to many of its powerful features. There is no need to leave a space on either side of it, except to make it more readable.

Enter x to check that x is a vector; it is a row vector—consisting of 1 row and 11 columns. Note that the first command line creates a vector y by multiplying each element of x by the factor 2. The second command line is an array operation, creating a vector w by taking each element of y and dividing it by the corresponding element of x. Since each element of y is two times the corresponding element of x, the vector w is a row vector of 11 elements all equal to 2.

Finally, z is a vector with sin x as its elements. To draw the graph of the sine function illustrated in Figure 1. The Windows pull-down menus can be used in any of them. Note that the first command line above has three numbers after the equal sign. When three numbers are separated by two colons in this way, the middle number is the increment.

The increment of 0. The command grid following the comma in the last command line adds a grid to the graph. Modifying the plot function as illustrated above, of the many options available within this function, four were selected. This selects a solid red line -r to connect the points at which the sine is computed; they are surrounded by square s markers in the figure. The line width is increased to 2 and the marker edge color is black k with size 5. Axis labels and the background color were changed with the statements following the plot command.

Additional changes in background color, object colors etc. Many of the colors in the figures in this book were modified with the figure-editing tools. Try drawing the graph of tan x over the same domain. You may find aspects of your graph surprising. To help examine this function you can improve the graph by using the command axis [0 10 10] as follows:. Note that the default domain of x in ezplot is not 0 to If the name is unique, it is automatically completed. If it is not unique, press Tab a second time to see all the possibilities. Try by typing ta at the command line followed by Tab twice.

Systems of linear equations are very important in engineering and scientific analysis. Matrix method. Built-in solve function. We will examine the need for comments when we learn to develop coded programs of command lines later on. You may wish to review the tutorials appropriate to the topics you are examining as part of your technical computing needs.

The first time it does this, there are no items in the folder and, hence, the Current Folder panel will be empty. This new folder in your Documents is the default working folder where all the files your create are saved. The location of this folder is given in the first toolbar above the Command Window. This format of the location was determined by pointing and left-clicking the mouse in the line just above the Command Window. Let us examine the Desktop from the top down.

On the right side of the top line are three buttons. On the next line of the Desktop there are three tabs on the left side. The first tap is most forward in the figure and, hence, the Home toolbar is displayed the tabs and the toolbars associated with the tabs are the main new features of this release of MATLAB. Point and click on the New Script icon on the left most side of the Home toolbar. Doing this opens the editor in the center of the Desktop as shown in. Figure 1. Note that three new tabs appear and that the tab that is visible is the Editor tab that is connected with the Editor.

The other two tabs are Publish and View. The latter are useful when creating notebooks or other documents connected with your technical computing work. The application of these tools will be illustrated by an example later in this text. Let us first consider using the Editor.

Then click on the Run button just under the tab named View. The first time the script is executed you are asked to name the file. The IPredicted matrix is supposed to be the identity matrix, IM. The matrix IPredicted was determined by multiplying the matrix A by its numerically computed inverse, AI. The last print out of IPredicted is a modification of the original matrix; it was changed to the elements of the IM matrix if the difference between a predicted and an actual element of IM was less than. Since the result is identical to the identity matrix, this shows that the inverse was computed correctly at least to within the computational error of the computing environment, i.

This conclusion is a result of the fact that the ans in the above example produced the logical result of 1 or true for all entries in the adjusted IPredicted matrix as logically compared with the corresponding entries in IM. At this point in the exercise the Desktop looks like Figure 1. It appears in the Current Folder and it also appears in the Command History. Note that the Workspace is populated with the variables created by this script. The conversion of the information typed into an M-file is published into a document that looks like the new Help environment.

### Stay ahead with the world's most comprehensive technology and business learning platform.

To open the help documents go to the top of the Desktop to the question mark. Left click on the question mark?. The Help window opens up. This also illustrates the new format. To illustrate how easy it is to create documents like the MATLAB documents, let us consider the following simple example. Click the New Script button to open up the editor or type edit after the command prompt in the Command Window followed by tapping the enter key. The Editor tab is in the most forward position on the main taskbar. Left click Section with Title. This is followed by a blank line and a command script; this command script is included to illustrate how MATLAB commands can be incorporated into published documents.

The final step is to left-click on Publish, which is just to the right and below View. The first window to appear is the one asking you to save the M-file. The name used in this example is ExamplePub1. After it appears in the Current Folder it is executed. A folder named html is automatically created and it contains the html document just created.

The document is illustrated in Figure 1. Finally, the VIEW tab brings up a toolbar that allows you to change the configuration of the Editor window. From the authors point of view, the default Editor environment is fine as is especially for users who are beginning to use MATLAB for technical computing. However, it is useful to learn how to deal with the default environment before deciding what needs to be changed to help satisfy your own requirements for using MATLAB.

The window in Figure 1. The left bracket on the upper left side of the white note pad is where the commands are typed. The panel on the right side of the pad is the Command Bar. It provides easy access to many of the commands needed to do mathematics including the manipulation and evaluation of mathematical expressions as well as plotting graphs. The two toolbars above the pad provide useful utilities to enhance your usage of MuPAD.

Moving the cursor over the items on the second line tells you what each button. The first line requires moving the cursor over them and a left-click on the mouse to open the pull-down menu. Let us examine a simple example. Left-click in the note pad just above the left bracket. At this location you can start typing text i. This note-. Double-left clicking on the file with this filename in the Command Folder panel opens this notebook as it is illus-. The details of this example are also provided in the figure.

They are as follows:. Differentiation and integration In this note we are going to examine a few of the mathematical commands available to us and listed in the Command Bar. Let us begin with taking the derivative of a function f. With the cursor placed on the upper left most symbol, a left-click on the mouse produces the following result: diff f, x.

The sign is a place holder at which input is required. The next step is to point to the right of the left bracket below and left-click to place the note pad cursor at this location. Then click on the command of interest in the Command Bar. Then hit enter to execute the command. Left-click on this operation in the Command Bar to get: int f, x.

Replace f with S1 and x with x. The only issue, if any, that you must keep in mind is that the constants of integration are set to zero. If you need to explicitly carry them along in your analysis, then you must add a constant to the results at this step. The help can be accessed by a left click on the blue circle with the question mark in the toolbar just above this pad.

A second example is the graphics capabilities in MuPAD. The MuPAD environment is particularly well suited for this kind of investigation. Suppose you are reading a technical article and you come across two interesting functions and you want to have an idea as to what they look like. Let us examine two examples. One is the sech2 x function which plays an important role in nonlinear wave theory. The second is the complete.

This integral plays an important role in potential theory. What do these functions look like? More on these functions among other functions can be examined in the help documentation and in the references cited in the help documentation. This concludes this brief introduction to an APP and a brief introduction to the capabilities of the Symbolic Math toolbox.

In addition, there is a capability for you to create your own APPS. Hence, if there is anything that we learn from our first experiences with MATLAB is that there is a lot to learn a lifelong experience of learning because of the wealth of technology incorporated in this technical computing environment. The fact that you can develop your own toolboxes, your own APPS and you can customize your working environment desktop arrangement, color backgrounds, fonts, graphical user interfaces and so on provides real opportunities and useful experience in creating designs, creating useful tools and documenting your work.

You can even get a contour plot of the elements of a magic square. MATLAB pretends that the elements in the square are heights above sea level of points on a map, and draws the contour lines. If you want to see the famous Mexican hat Figure 1. The following animation is an extension of the Mexican hat graphic in Figure 1. The execution of the commands between the for and end statements repeat times in this example. The pause 0. One way is to listen to the signal. For different sounds try loading chirp, gong, laughter, splat, and train. You have to run sound y,Fs for each one. Try why why not?

Then try why 2 twice. The edit command will be used soon to illustrate the creation of an M-file like why. In Section 1. A collection of statements to solve such a problem is called a program. In this section we look at the mechanics of writing and running two short programs, without bothering too much about how they work—explanations will follow in the next chapter.

The Windows environment lends itself to nifty cut and paste editing, which you would do well to master. Proceed as follows. Next, move the mouse pointer which now looks like a very thin capital I to the left of the x in the first line. Keep the left mouse button down while moving the mouse pointer to the end of the second line. This process is called dragging. Both lines should be highlighted at this stage, probably in blue, to indicate that they have been selected. This action copies the highlighted text to the Windows clipboard, assuming that your operating system is Windows.

Now go back to the Command Window. The contents of the clipboard will be copied into the Command Window. To execute the two lines in the program, press Enter. The graph should appear in a figure window. If you need to correct the program, go back to the Editor, click at the position of the error this moves the insertion point to the right place , make the correction, and cut and paste again.

Alternatively, you can use command-line editing to correct mistakes. As yet another alternative, you can paste from the Command History window which incidentally goes back over many previous. To select multiple lines in the Command History window keep Ctrl down while you click. If you prefer, you can enter multiple lines directly in the Command Window. Then press Enter to run all the lines. What will your bank balance be after one year? Now, if you want to write a MATLAB program to find your new balance, you must be able to do the problem yourself in principle.

Even with a relatively simple problem like this, it often helps first to write down a rough structure plan: 1. Display the new balance. Go back to the Editor. By the way, to de-select highlighted text, click anywhere outside the selection area.

## Essential Matlab for Engineers and Scientists

Enter the following program, and then cut and paste it to the Command Window. Obviously you need to save the program if you want to use it again later. A Save file as: dialogue box appears. Select a folder and enter a file name, which must have the extension. The Editor window now has the title junk. If you make subsequent changes to junk. We therefore refer to both script and function files generally as M-files. The special significance of a script file is that, if you enter its name at the command-line prompt, MATLAB carries out each statement in the script file as if it were entered at the prompt.

As an example, save the compound interest program above in a script file under the name compint. Then simply enter the name compint at the prompt in the Command Window as soon as you hit Enter. The statements in compint. A script file may be listed in the Command Window with the command type, e.

Script files provide a useful way of managing large programs which you do not necessarily want to paste into the Command Window every time you run them. To change the current folder type the path for the new current folder in the toolbar, or select a folder from the dropdown list of previous working folders, or click on the browse button it is the first folder with the green arrow that is to the left of the field that indicates the location of the Current Folder. Select a new location for saving and executing files e. You can change the current folder from the command line with cd command, e.

Running a script from the current folder browser A handy way to run a script is as follows. Select the file in the Current Directory browser. Right-click it. The context menu appears context menus are a general feature of the desktop.

Select Run from the context menu. The results appear in the Command Window. If you want to edit the script, select Open from the context menu. We will now discuss in detail how the compound interest program works. This means that each statement presented to the command line is translated interpreted into language the computer understands better, and then immediately carried out. You can think of this part of the memory as a bank of boxes or memory locations, each of which can hold only one number at a time.

Since the contents of balance may be changed during a session it is called a variable. Put the number into variable balance. Put the number 0. Multiply the contents of rate by the contents of balance and put the answer in interest. Add the contents of balance to the contents of interest and put the answer in balance. Display in the Command Window the message given in single quotes.

Display the contents of balance. It hardly seems necessary to stress this, but these interpreted statements are carried out in order from the top down. When the program has finished running, the variables used will have the following values: balance : interest : 90 rate : 0. Try the following exercises: 1. Run the program as it stands.

- Microeconomics: A Critical Companion.
- Colonial Justice in British India: White Violence and the Rule of Law.
- Essential Matlab for Engineers and Scientists, 6th Edition by vinicius.s.c - Issuu.
- 4th Edition.

Can you explain what happens? Try to rewrite the program so that the original value of balance is not lost. What names may be used for variables? How can numbers be represented? How can we organize the output more neatly? These questions will be answered in the next chapter. However, before we write any more complete programs there are some additional basic concepts which need to be introduced. These concepts are introduced in the next chapter. MATLAB is a matrix-based computer system designed to assist in scientific and engineering problem solving.

They are carried out immediately. Write some statements to find the sum, difference, product and quotient of a and b. Type this into the editor, save it and execute it. Once you finish debugging it and it executes successfully try modifying it. What is the square root of x? What is the cosine of the square root of x? What is the square root of y? Hence the symbol i should not be used as an index or as a variable name. Hence, it also should not be used as an index or as a variable name.

Give an example of how you have used complex numbers in your studies of mathematics and the sciences up to this point in your education. Solutions to many of the exercises are in Appendix D. Variables, operators, and expressions Arrays including vectors and matrices Basic input and output Repetition for Decisions if. The tools introduced in this chapter are sufficient to begin solving numerous scientific and engineering problems you may encounter in your course work and in your profession. The last part of this chapter and the next chapter describe an approach to designing reasonably good programs to initiate the building of tools for your own toolbox.

In a sense, the art of programming is this: Getting the right values in the right variables at the right time. Arrays: Vectors and matrices A variable name like the variable balance that we used in Chapter 1 must comply with the following two rules:. It must start with a letter. Operator precedence Repeating with for Examples of invalid names why? Undefined function or variable The official MATLAB documentation refers to all variables as arrays, whether they are single-valued scalars or multi-valued vectors or matrices.

In other words, a scalar is a 1-by-1 array—an array with a single row and a single column which, of course, is an array of one item. Many programmers write variable names in lowercase except for the first letter of the second and subsequent words, if the name consists of more than one word run together. Some programmers prefer to separate words with underscores. Command and function names are also case-sensitive. However, note that when you use the command-line help, function names are given in capitals e.

You must not use capitals when running built-in functions and commands! Enter the command clear and then rerun the compound interest program see Section 1. Now enter the command who. You should see a list of variables as follows:. All the variables you create during a session remain in the workspace until you clear them. You can use or change their values at any stage during the session.

The command who lists the names of all the variables in your workspace. The function ans returns the value of the last expression evaluated but not assigned to a variable. The command whos lists the size of each variable as well: Name. Each variable here occupies eight bytes of storage. A byte is the amount of computer memory required for one character if you are interested, one byte is the same as eight bits. The Class double array means that the variable holds numeric values as double-precision floating-point see Section 2. The command clear removes all variables from the workspace.

A particular variable can be removed from the workspace e. More than one variable can also be cleared e. Separate the variable names with spaces, not commas. When you run a program, any variables created by it remain in the workspace after it runs. This means that existing variables with the same names are overwritten. The Workspace browser on the desktop provides a handy visual representation of the workspace. You can view and even change the values of workspace variables with the Array Editor. To activate the Array Editor click on a variable in the Workspace browser or right-click to get the more general context menu.

- Molecular Biology of the Cell (6th Edition)?
- Science (Vol. 308, No. 5730, June 2005).
- Locarno Revisited: European Diplomacy 1920-1929 (Diplomats and Diplomacy);
- Shop by category.
- Introduction To The Theory Of Neural Computation, Volume I?
- Essential Matlab for Engineers and Scientists.
- Ebook Essential Matlab For Engineers And Scientists, Fourth Edition ;

From the context menu you can draw graphs of workspace variables in various ways. If you often use the same physical or mathematical constants in your MATLAB sessions, you can save them in an M-file and run the file at the start of a session. For example, the following statements can be saved in myconst. Complex numbers If you run myconst at the start of a session, these six variables will be part of the workspace and will be available for the rest of the session or until you clear them. A matrix is a rectangular object e.

A vector is a special type of matrix, having only one row or one column. Vectors are called lists or arrays in other programming languages. MATLAB handles vectors and matrices in the same way, but since vectors are easier to think about than matrices, we will look at them first. We will also use the term array generally, with vector and matrix referring to the one-dimensional 1D and two-dimensional 2D array forms.

These are all examples of the explicit list method of initializing vectors. Exercises 2.

- Redrawing the Class Map: Stratification and Institutions in Britain, Germany, Sweden and Switzerland!
- Transgression: A Novel of Love and War;
- Focal Points in Framed Games: Breaking the Symmetry.

Make sure to leave out the semicolon so that you can see the list. Also, make sure you hit Enter to execute the command. Under the heading Size you will see that x is 1 by 5, which means 1 row and 5 columns. You will also see that the total number of elements is 5. Take the space between the minus sign and 15 to see how the assignment of x changes. An empty array may be used to remove elements from an array see Section 2. Elements in the list must be enclosed in square brackets, not parentheses.

## Essential MATLAB for Engineers and Scientists by Brian D. Hahn

Elements in the list must be separated either by spaces or by commas. A vector can also be generated initialized with the colon operator, as we saw in Chapter 1. The function logspace can be used to generate logarithmically spaced data. It is a logarithmic equivalent of linspace. If the last number in this function call is omitted, the number of values of y computed is by default What is the interval between the numbers 1 and in this example?

To compute the distance between the points you can implement the following command:. Thus, the logspace function produces a set of points with an interval between them that increases linearly with y. The variable yy was introduced for two reasons. The first was to generate a vector of the same length as dy. The second was to examine the increase in the interval with increase in y that is obtained with the implementation of logspace. All of the vectors examined so far are row vectors.

### About the author

Each has one row and several columns. To generate the column vectors that are often needed in mathematics, you need to transpose such vectors—that is, you need to interchange their rows and columns. Note that x itself remains a row vector. We can refer to particular elements of a vector by means of subscripts. Try the following: 1. This gives you a row vector of seven random numbers. Enter r 3. This will display the third element of r. The numeral 3 is the subscript. Enter r This should give you the second, third, and fourth elements.

What about r and r [1 7 2 6]? A subscript is indicated by parentheses. A subscript may be a scalar or a vector. Fractional subscripts are not allowed. You create a matrix just as you do a vector, except that a semicolon is used to indicate the end of a row. A matrix can be constructed from column vectors of the same length. Generate the table of angles and sines as shown above. Select all seven rows of numerical output. You can then edit the output, for example, by inserting text headings above each column this is easier than trying to get headings to line up over the columns with a disp statement.

The edited output can in turn be pasted into a report or printed as is the File menu has a number of printing options. Another way of capturing output is with the diary command. The command diary. Stop recording the session with diary off Note that diary appends material to an existing file—that is, it adds new information to the end of it. A structure plan is a top-down design of the steps required to solve a particular problem with a computer. It is typically written in what is called pseudo-code— that is, statements in English, mathematics, and MATLAB describing in detail how to solve a problem.

Loops 9. Vectors as Arrays and other Data Structures Dynamical Systems Simulation Introduction to Numerical Methods Signal Processing Symbolics Toolbox Complex Variables Applications. See All Customer Reviews. Shop Textbooks. Read an excerpt of this book!