RUDRA PRATAP MATLAB EBOOK

adminComment(0)

Kindle Price: inclusive of all taxes includes free wireless delivery via site Whispernet. Sold by: site Asia-Pacific Holdings Private Limited. (r) Familiarizes users with MATLAB in just a few hours though self-guided Rudra Pratap is Professor of Mechanical Engineering at the Indian Institute of. download INTRODUCTION TO MATLAB: Read Kindle Store Reviews - kaz-news.info


Rudra Pratap Matlab Ebook

Author:TOMMIE HOLLYFIELD
Language:English, Indonesian, Japanese
Country:Benin
Genre:Children & Youth
Pages:529
Published (Last):24.11.2015
ISBN:355-8-60057-186-1
ePub File Size:21.84 MB
PDF File Size:14.83 MB
Distribution:Free* [*Registration Required]
Downloads:37481
Uploaded by: DUDLEY

Matlab ebook by rudra pratap singh Preface 1 1 Introduction 3 What Is MATLAB? 3 Does MATLAB Do. Author: Rudra Pratap Pages: Publication Date Release Date: ISBN: Product Group:Book Download Download. getting started with matlab by rudra pratap ebook, getting started with matlab by rudra pratap pdf, getting started with matlab by rudra pratap doc and getting.

The design of the language makes it possible to write a powerful program in a few lines. As a result, MATLAB is being used in a wide variety of domains from the natural sciences through all disciplines of engineering to finance and beyond, and it is heavily used in industry.

It is an introductory programming course that happens to use MATLAB to illustrate general concepts in computer science and programming.

This is an introductory college-level course in computer science for engineering and science students. However, it is also suitable for high school students who are interested in programming. The material assumes no background in mathematics beyond the standard high school curriculum. The ability to formulate an engineering problem in a mathematical form appropriate for subsequent computational treatment and to choose an appropriate numerical approach.

A commitment to always provide with any numerical prediction or recommendation some indication of error and uncertainty—and associated engineering implications—due to numerical treatment and modeling error, however the latter is the emphasis of other MechE subjects.

About the Course MATLAB is a special-purpose language that is an excellent choice for writing moderate-size programs that solve problems involving the manipulation of numbers. Students who successfully complete this course will: Course Syllabus The course is divided into the following 8 weekly modules: Finding eigenvalues and eigenvectors. Scripts and Functions 85 4. A rst-order linear ODE. A second-order nonlinear ODE.

I used to think in terms of machine-specic compilers and tables of numbers as output. Now, I expect and enjoy interactive calculation, programming, graphics, animation, and complete portability across platformsall under one roof. It is not a complete miracle drug, but I like it and I think you will probably like it too. Although the graphics capability was limited to bare-bones 2-D plots, and programming was not possible on the mainframe VAX, I still loved it. I did all the computations for my Ph.

I have given several introductory lectures, demonstrations, and hands-on workshops. This book is a result of my involvement with MATLAB teaching, both informal and in the class room, over the last several years. This book is intended to get you started quickly. After an hour or two of getting started you can use the book as a reference.

There are many examples, which you can modify for your own use. If you nd the book informative and useful, it is my pleasure to be of service to you. If you nd it frustrating, please share your frustrations with me so that I can try to improve future editions. This update re- quired checking each command and function given in this book as examples, and changing them if required. New versions of software packages usually add fea- tures that their experienced users ask for.

As a result, the packages and their 2 Preface manuals get bigger and bigger, and more intimidating to a new user. I have tried hard to protect the interests of a new user in this book. It has been a struggle to keep this book lean and thin, friendly to beginners, and yet add more features and applications.

In response to emails I have received from several readers across the globe, I have added more exercises in this edition. I have also added substantial material in Chapter 3 Interactive Computation and Chapter 5 Applications. I was helped through the development of this book by the encouragement, criticism, editing, typing, and test-learning of many people, especially at Cornell University and the Indian Institute of Science. I thank all students who have used this book in its past forms and provided constructive criticism.

A Quick Introduction for Scientists and Engineers

I have also been fortunate to receive feedback by email, sometimes quite attering, from several readers all over the world. I greatly appreciate your words of encouragement.

Hall, James R.

Wohlever, John T. Demel, Jerey L. Cipolla, John C. In addition, I must acknowledge the help of three special people. Andy Ruina has been an integral part of the development of this book all along. In fact, he has written most of Chapter 8, the introduction to the Symbolic Math Toolbox. That apart, his criticisms and suggestions have inuenced every page of this book.

My ed- itor Peter Gordon at Oxford University Press has always been supportive and kept his word on keeping the price of the book low. Lastly, I thank my wife, Kalpana, for being incredibly supportive through- out.

The rst edition of this book came out in , just after our daughter, Manisha, was born. Despite their arrival, if this edition of the book is in your hands, it is because of my wife who provided me with the time to work on the book by shouldering more than her fair share of family responsibilities.

Thank you all. Bangalore Rudra Pratap. May, Introduction 1. It provides an interactive environment with hundreds of built-in functions for technical computation, graphics, and animation.

Best of all, it also provides easy extensibility with its own high-level pro- gramming language. The diagram in Fig. MATLABs built-in functions provide excellent tools for linear alge- bra computations, data analysis, signal processing, optimization, numerical solution of ordinary dierential equations ODEs , quadrature, and many other types of scientic computations.

Most of these functions use state-of- the art algorithms. There are numerous functions for 2-D and 3-D graphics as well as for animation. Once written, these functions behave just like the built-in functions.

The fundamental data-type is the array. Vectors, scalars, real matrices and complex matrices are all automatically handled as special cases of the basic data-type. What is more, you almost never have to declare the dimensions of a matrix. Consequently, vectorized 1. See Section 8. Mathematica, Maple, and Macsyma are primarily symbolic algebra packages.

Of course, they do numerical computations too. In fact, if you know any of these packages really well, you can do almost every calcu- lation that MATLAB does using that software. Also, it has a shallow learning curve more learning with less eort while the computer algebra systems have a steep learning curve. There are other packages, such as Xmath, that are also closer in aim and scope but seem to be popular with people in some specialized application areas.

The bottom line is, in numerical computations, especially those that utilize vectors and matrices, MATLAB beats everyone hands down in terms of ease of use, availability of built-in functions, ease of programming, and speed. There are more than universities and thousands of companies listed as registered users.

For example, let be a list of numbers. Software packages that do symbolic algebra are also known as Computer Algebra Systems. To nd out more about product availability for your particular computer, see the MathWorks homepage on the website given below. Contact the com- pany for product information and ordering at the following address: The MathWorks Inc. The goal is to get started as simply as possible. It takes a while to understand its real power.

Unfortunately, most powerful packages tend to be somewhat intimidating to a beginner. That is why this book exists to help you overcome the fear, get started quickly, and become productive in very little time. The most useful and eas- ily accessible features of MATLAB are discussed rst to make you productive and build your condence.

Several features are discussed in sucient depth, with an invitation to explore the more advanced features on your own. All features are discussed through examples using the following conventions: Typographical styles: Place holders for variables or names in a command are shown in italics.

So, a command shown as help topic implies that you have to type the actual name of a topic in place of topic in the command. Italic text has also been used to emphasize a point and sometimes, to introduce a new term. Explanatory notes have been added within small white rectangles in the gray boxes as shown below. The texts in the white boxes inside these gray boxes are explanatory notes.

These gray, boxed gures are intended to provide a parallel track for the impatient reader. Most of the ex- amples are designed so that you can more or less follow them without reading the entire text. All examples are system-independent. After trying out the examples, you should read the appropriate sections. On-line help: We encourage the use of on-line help. For almost all major topics, we indicate the on-line help category in a small box in the margin as shown here.

For on-line help type: Detailed help can then be obtained for any of those commands and functions. We discourage a passive reading of this book.

The best way to learn any computer software is to try it out. We believe this, practice it, and encourage you to practice it too. So, if you are impatient, quickly read Sections 1. Command window: This is the main window. If you can get to the command window, we advise you to ignore the other four subwindows at this point.

As software packages, such as MATLAB, become more and more powerful, their creators add more and more features to address the needs of experienced users. Unfor- tunately, it makes life harder for the beginners there is more room for confusion, distraction, and intimidation.

Although, we describe the other subwindows here that appear with the command window, we do not expect it to be useful to you till you get to Lesson 6 in Chapter 2. Launch Pad: You can launch any of the listed applications by double clicking on them.

This subwindow lists all variables that you have gen- erated so far and shows their type and size. You can do various things with these variables, such as plotting, by clicking on a vari- able and then using the right button on the mouse to select your option. Command History: All commands typed on the MATLAB prompt in the command window get recorded, even across multiple ses- sions you worked on Monday, then on Thursday, and then on next Wednesday, and so on , in this window.

You can select a command from this window with the mouse and execute it in the command window by double clicking on it. You can also select a set of commands from this window and create an M-le with the right click of the mouse and selecting the appropriate option from the menu.

Current Directory: This is where all your les from the current di- rectory are listed. You can do le navigation here. You also have 1. To see the options, click the right button of the mouse after selecting a le. You can run M-les, rename them, delete them, etc. Graphics window: The output of all graphics commands typed in the command window are ushed to the graphics or Figure window, a separate gray window with default white background color. The user can create as many gure windows as the system memory will allow.

Edit window: This is where you write, edit, create, and save your own programs in les called M-les. You can use any text editor to carry out these tasks. However, you can use your own editor by typing the standard le-editing command that you normally use on your system. The exclamation character prompts MATLAB to return the control temporarily to the local operating sys- tem, which executes the command following the!

For example, on Unix systems, typing! The com- mands lookfor, help, helpwin, and helpdesk provide on-line help. See Section 3. The program includes a tutorial introduction that is worth trying. In addition, it can read input les and write output les see Section 4.

The following features hold for all forms of input-output: Data type: The Figure and the Editor windows appear only when invoked with the appropriate commands. For example, there is no need to declare variables as real or complex. No dimen- sion statements are required for vectors or arrays. You can nd the dimensions of an existing matrix or a vector with the size and length for vectors only commands.

Case sensitivity: Thus a and A are dierent variables. You can turn case sensitivity on and o with the casesen command. However, we do not recommend it.

Output display: A semicolon at the end of a command suppresses the screen output, except for graphics and on-line help commands. The following facilities are provided for con- trolling the screen output: Paged output: Output format: Though computations inside MATLAB are per- formed using double precision, the appearance of oating point numbers on the screen is controlled by the output format in use. There are several dierent screen output formats. The following table shows the printed value of 10 in 7 dierent formats.

See Section 4. We do not discuss this facility in this book. The default is format short. The display format is set by typing format type on the command line see Fig. Command history: These commands can be recalled with the up-arrow key. This helps in editing previous commands. You can also recall a previous command by typing the rst few characters and then pressing the key.

Alternatively, you can copy and paste commands from the Command History subwindow where all your commands from even previous sessions of MATLAB are recorded and listed. There are two types of these les: Some built-in func- tions are provided with source code in readable M-les so that they can be copied and modied.

Mat-les are binary data-les, with a. We do not discuss Mex-les in this introductory book. Almost all commands work the same way. The only commands that dier are the ones that necessarily depend on the local operating system, 1. The user interface how you interact with your computer , however, may vary a little from platform to platform. On PCs: On Unix machines: Type matlab on the Unix prompt and hit re- turn. If it is not, ask your system administrator.

Creating a directory and saving les: You can save all your work in this folder and access all your les easily default set-up. If not, you have to create a separate folder for saving your work. The most convenient place, however, to save all user-written les is in a directory or folder immediately below the directory or folder in which the MATLAB ap- plication program is installed for PCs.

If you need to store the les somewhere else, you might have to specify the path to the les using the path command, or change the working directory of MATLAB to the desired directory with the cd command. We recommend the latter. If you are not allowed to write in the MATLAB folder as may be the case in some shared facilities , then create a folder where you are allowed perhaps on your own oppy disk , copy the le startup.

You should also personalize the Startup le by editing it and adding a line, say, disp Hello Kelly, Welcome Aboard. To open, write, and save M-les, use a text editor such as vi or emacs.

To print the contents of the current active window com- mand, gure, or edit window , select Print For example, to print the le startup. Although, many of these things would probably not make sense to you right now, they are here, and you can come back to them whenever they seem relevant. The Current Directory is shown just above the Command Window with the option of changing the current directory with just a click of the mouse. In addition, there is a Current Directory subwindow to the left of the Command Window that lists les in the current directory, gives you options of opening, loading a.

Not being in the right directory: Use dir or ls at the command prompt to see if MATLAB lists your les or click on the Current Direc- tory tab to the left of the command window to see the listing of les in that subwindow. Use cd or path; cd is easier to use but applies only to the current session.

With path command, you can save the path to your directory and have MATLAB automatically access your directory every time you use it. Use the on-line help to see how to set the path. Also, see Lesson-6 in the tutorials Chapter 2.

Not saving les in the correct directory: Not overwriting an existing le while editing: You run your pro- gram by executing your M-le, do not like the result, edit the le, and run it again; but MATLAB gives the same answer! This can happen due to various reasons.

Simple cure is, clear the workspace with clear all and execute your le. There are various other little things that cause trouble from time to time. We point them out throughout the book wherever they raise their head. Each lesson should take about minutes.

We urge you also to do the exercises given at the end of each lesson.

This will take more time, but it will teach you quite a few things. If you get stuck in the exercises, simply turn the page; answers are on the back.

Most answers consist of correct commands to do the exercises. But there are several correct ways of doing the problems. So, your commands might look dierent than those given. Before You Start You need some information about the computer you are going to work on. In particular, nd out: How to switch on the computer and get it started. How to log on and log o. Where you can write and save leshard drive or a oppy disk. If there is a printer attached to the computer. If you are working on your own computer, you will most likely know the answer to these questions.

If you are working on a computer in a public facility, the system manager can help you. In public facilities, sometimes the best thing to do is to spot a friendly person working there and ask these questions politely. People are usually nice! Here are the lessons in a nutshell: Key features: Learn to add, multiply, and exponentiate numbers, use trig functions, and control screen output with format.

Create and work with arrays, vectors in particular.

Learn to create, add, and multiply vectors, use sin and sqrt functions with vector arguments, and use linspace to create a vector. Plot simple graphs. Learn to plot, label, and print out a circle. Write and execute a script le. Learn to write, save, and execute a script le that plots a unit circle.

Write and execute a function le. Learn to write, save, and execute a function le that plots a circle of any specied radius. Learn about le and directory navigation.

Time Estimates: How to do simple arithmetic calculations. The arithmetic operators are: How to assign values to variables. How to suppress screen output. How to control the appearance of oating point numbers on the screen. Some commands and their output are shown below. Go ahead and reproduce the results. Note that the result of an un- assigned expression is saved in the default variable ans. You can also assign the value of an expression to a variable.

A semicolon at the end suppresses screen output. You can recall the value of y by simply typing y. Here is arccosine of The floating point output display is controlled by the format command.

Here are two examples. More info on this later. You can also quit by selecting quit from the file menu on Macs and PCs. Arithmetic operations: Compute the following quantities:. Exponential and logarithms: The mathematical quantities e x , lnx, and log x are calculated with exp x , log x , and log10 x , respec- tively. Calculate the following quantities: You can verify the result by direct substitution.

The inverses, e. The same is true for hyperbolic functions. The inverse function atan2 takes 2 arguments, y and x, and gives the four-quadrant inverse tangent.

The argument of these functions must be in radians. Complex numbers: The former case is always interpreted as a complex number whereas the latter case is taken as complex only if i has not been assigned any local value. The same is true for j. Compute the following quantities. Can you explain the dierence between the two results? Command Result exp 3 Working with Arrays of Numbers 25 2. Creating and Working with Arrays of Numbers Goal: To learn how to create arrays and vectors, and how to perform arithmetic and trigonometric operations on them.

An array is a list of numbers or expressions arranged in horizontal rows and vertical columns. When an array has only one row or column, it is called a vector.

An array with m rows and n columns is a called a matrix of size m n. How to create row and column vectors. How to create a vector of n numbers linearly equally spaced between two given numbers a and b. How to do simple arithmetic operations on vectors. How to do array operations: How to use trigonometric functions with array arguments.

Matlab rudrapratap - Getting Started with MATLAB A Quick

How to use elementary math functions such as square root, exponen- tials, and logarithms, with array arguments. This lesson deals primarily with one-dimensional arrays, i. One of the exercises introduces you to two-dimensional arrays, i.

There are many mathematical concepts associated with vectors and matrices that we do not mention here. If you have some background in linear algebra, you will nd that MATLAB is set up to do almost any matrix computation e.

So go ahead and try the commands shown on the next page. Once again, you are going to reproduce the results shown. But you cannot add or subtract a row vector to a column vector. You can add or subtract two vectors of the same size. Create a vector x with 5 elements linearly spaced between 0 and Trigonometric functions sin, cos, etc. Figure 2.

GETTING STARTED WITH MATLAB-RUDRAPRATAP

Some simple calculations with vectors. Equation of a straight line: Your command should not involve any array operators since your cal- culation involves multiplication of a vector with a scalar m and then addition of another scalar c.

Multiply, divide, and exponentiate vectors: Create a vector t with 10 elements: Now compute the following quantities: Points on a circle: Of course, you could compute x 2 by x.

The geometric series: This is funky! You know how to compute x n element-by-element for a vector x and a scalar exponent n. How about com- puting n x , and what does it mean? The result is again a vector with elements n x1 , n x2 , n x3 etc. Create a vector n of 11 elements from 0 to Calculate the limit 1 1r and compare the computed sum s. Repeat the procedure taking n from 0 to 50 and then from 0 to Matrices and vectors: Go to Fig.

Now create a vector and a matrix with the following commands: Find the sizes of v and M using the size com- mand. Extract the rst 10 elements of each row of the matrix, and display them as column vectors. The last command M: Creating and Printing Simple Plots 29 2. Creating and Printing Simple Plots Goal: How to generate x and y coordinates of equidistant points on a unit circle.

How to plot x vs y and thus create the circle. How to set the scale of the x and y axes to be the same, so that the circle looks like a circle and not an ellipse. How to label the axes with text strings. How to title the graph with a text string. How to get a hardcopy of the graph. The MATLAB commands used are plot creates a 2-D line plot axis changes the aspect ratio of x and y axes xlabel annotates the x-axis ylabel annotates the y-axis title puts a title on the plot, and print prints a hardcopy of the plot.

This lesson teaches you the most basic graphics commands. The exercises take you through various types of plots, overlay plots, and more involved graphics. You are going to draw a circle of unit radius.

To do this, rst generate the data x- and y-coordinates of, say, points on the circle , then plot the data, and nally print the graph. For generating data, use the parametric equation of a unit circle: In the sample session shown here, only the commands are shown. You should see the output on your screen.

Calculate x and y coordinates. Plot x vs. Label the x-axis with x. Label the y-axis with y. Put a title on the plot.

Print on the default printer. Plotting and printing a simple graph. After you enter the command plot x,y , you should see an ellipse in the Figure Window. The next command axis equal , directs MATLAB to use the same scale on both axes, so that a circle appears as a circle. You can also use axis square to override the default rectangular axes. The arguments of the axis, xlabel, ylabel, and title commands are text strings.

Text strings are entered within single right-quote. For more information on text strings, see Section 3. The print command sends the current plot to the printer connected to your computer. A simple sine plot: Label the axes and put Plot created by yourname in the title. Make the same plot as above, but rather than displaying the graph as a curve, show the unconnected data points. To display the data points with small circles, use plot x,y,o. You may peep into Section 6.

An exponentially decaying sine plot: You need array multiplication between exp Space curve: If too much text ashes by the screen, type more on, hit return, and then type help plot again. This should give you paged screen output.

Read through the on-line help. To move to the next page of the screen output, simply press the spacebar. Log scale plots: The plot commands semilogx, semilogy, and loglog, plot the x-values, the y-values, and both x- and y-values on a log 10 scale, respectively.

Overlay plots: You might like to read Section 6. You can use plot x,y,x,z,-- or you can plot the rst curve, use the hold on command, and then plot the second curve on top of the rst one. Fancy plots: Go to Section 6. Reproduce any of the plots you like. A very dicult plot: Use your knowledge of splines and interpolation to draw a lizard just kidding.

You should not be looking for answer here. If the last command legend does produce a legend on your plot, click and hold your mouse on the legend and see if you can move it to a location of your liking.

See page for more information on legend. Creating, Saving, and Executing a Script File 33 2. The le must be saved with a. A script le is executed by typing its name without the. For more information, see Section 4. How to create, write, and save a script le.

Unfortunately, creating, editing, and saving les are somewhat system dependent tasks. The commands needed to accomplish these tasks depends on the operating system and the text editor you use. It is not possible to provide an introduction to these topics here. You know how to open, edit, and save a le. You know which directory your le is saved in. Write a script le to draw the unit circle of Lesson You are essentially going to write the commands shown in Fig.

Follow the directions below. Create a new le: On PCs and Macs: Select New M-File from the File menu. A new edit window should appear.

On Unix workstations: Type the following lines into this le. Write and save the le under the name circle. Select Save As A dialog box should appear. Type the name of the document as circle.

Click Save to save the le. You are on your own to write and save the le using the editor of your choice. Execute the file. You should see the circle plot in the Figure Window.

Executing a script le. Show the center of the circle: Modify the script le circle to show the center of the circle on the plot, too. See Exercises 2 and 7 of Lesson 3. Change the radius of the circle: Modify the script le circle. Modify the x and y coordinate calculations appropriately. Save and execute the le. When asked, enter a value for the radius and press return. Variables in the workspace: All variables created by a script le are left in the global workspace. You can get information about them and access them, too: Type who to see the variables present in your workspace.

You should see the variables r, theta, x and y in the list. Type whos to get more information about the variables and the workspace. Type [theta x y] to see the values of , x and y listed as three columns. All three variables are row vectors. Typing a single right quote. Contents of the le: You can see the contents of an M-le without opening the le with an editor.

The contents are displayed by the type command. To see the contents of circle. H1 line: The rst commented line before any executable statement in a script le is called the H1 line. It is this line that is searched by the lookfor command. Since the lookfor command is used to look for M-les with keywords in their description, you should put keywords in H1 line of all M- les you create.

Does it list the script le you just created? Just for fun: Write a script le that, when executed, greets you, displays the date and time, and curses your favorite TA or professor.

See the on-line help on these commands before using them. Your changed script le should look like this: Here is a script le that you may not fully understand yet. Do not worry, just copy it if you like it.

See the on-line help on the commands used, e. Creating and Executing a Function File 37 2. Creating and Executing a Function File Goal: To learn how to write and execute a function le. Also, to learn the dierence between a script le and a function le. A function le is also an M-le, just like a script le, except it has a function denition line on the top that denes the input and output explicitly.

How to open and edit an existing M-le. How to dene and execute a function le. Write a function le to draw a circle of a specied radius, with the radius as the input to the function.

You can either write the function le from scratch or modify the script le of Lesson 4. We advise you to select the latter option. Open the script le circle. Select Open M-File from the File menu.

Navigate and select the le circle. Double click to open the le. The contents of the le should appear in an edit window. Edit the le circle. Now write and save the le under the name circlefn. Type the name of the document as circlefn. Click save to save the le. Here is a sample session that executes the function circlefn in three dierent ways. Try it out.

You can also specify the value of the input directly. If you dont need the output, you dont have to specify it. Executing a function le. Note that a function le see previous page must begin with a function denition line. To learn more about function les, refer to Section 4. The argument of the title command in this function le is slightly complicated.

To understand how it works see Section 3. Type help function to get on-line help on function. Read through the help le. Convert temperature: Write a function that outputs a conversion-table for Celsius and Fahrenheit temperatures. The input of the function should be two numbers: T i and T f , specifying the lower and upper range of the table in Celsius. The output should be a two column matrix: Note that your output will be named temp.

Calculate factorials: Write a function factorial to compute the factorial n! The input should be the number n and the output should be n!. You might have to use a for loop or a while loop to do the calculation. You can use the built-in function prod to calculate factorials. For example, n! In this exercise, however, do not use this function. Compute the cross product: Check your function by taking cross products of pairs of unit vectors: Do not use the built-in function cross here.

Sum a geometric series: Thus the input to the function must be r and n and the output must be the sum of the series. Calculate the interest on your money: Write a function to compute the interest X X 0 on your account for a given X, n, r, and k.

For screen output, use format bank. If so, look them up or ignore them.

GETTING STARTED WITH MATLAB-RUDRAPRATAP

This cross product is beyond me. Creating and Executing a Function File 41 5. Working with Files and Directories Goal: How to nd your bearings in the jungle of directories.

How to nd which of your M-les are accessible. How to change the working directory. MATLAB 6 includes several menu driven features which make le navigation much easier compared to the earlier versions.

You will explore some of these features now. In addition, you will also learn commands that pretty much do the same thing from the command line. The commands that you will use are pwd, dir, ls, cd, what, and path.

Let us go step by step. Where are you? The rst thing to nd is which directory you are currently in. This information is available in three ways: Look at the command window toolbar. There is a small win- dow that shows the name of the current directory along with its path. For example, Fig. As the path indicates, it is inside the matlabR12 directory.

Which directory are you in? Working with Files and Directories 43 2. You can get the same information from the command line by typ- ing pwd print working directory. The current directory is also displayed in a separate subwindow to the left of the command window. If it is not visible, click on the Current Directory tab. This subwindow also lists the contents of the current directory. How do you change the current directory? You can change the cur- rent directory with the cd DirectoryName command on the command line or by navigating through the browse button the button with three dots on it located next to the current directory peep-in window.

Make sure that after you change the directory, the new directorys name ap- pears in the current directory peep-in window. What are the contents of the current directory?

You can see the con- tents of the current directory in the Current Directory subwindow Fig. These commands list all the les and folders in the current directory. So, if you dont do any di- rectory navigation, all les that you create and save during a MATLAB session will be saved in the work directory.

However, you are not lim- ited to this directory for saving your les. You can create a directory 44 Tutorial Lessons Figure 2. This change, however, is eective only for the duration of the current session.Bachcha Singh Contents Preface 1 1 Introduction 3 1. If you are not allowed to write in the MATLAB folder as may be the case in some shared facilities , then create a folder where you are allowed perhaps on your own oppy disk , copy the le startup.

Save and execute the le. Make the same plot as above, but rather than displaying the graph as a curve, show the unconnected data points. The left division: