GETTING STARTED WITH MATLAB-RUDRAPRATAP - Free ebook download as PDF File .pdf), Text File .txt) or read book online for free. MATLAB. The purpose of this tutorial is to familiarize the beginner to MATLAB, by introducing the basic features Rudra Pratap, Saunders College Publishing, The document is written as a PDF, with internal links as well as links to MATLAB: A Quick Introduction for Scientists and Engineers (Rudra Pratap, ).
|Language:||English, Spanish, German|
|Genre:||Children & Youth|
|Distribution:||Free* [*Registration needed]|
MATLAB, a software package for high-performance numerical computation and visualization, is one of the most widely used tools in the engineering field today. are the modified versions of the items from Rudra Pratap's, Getting started with Matlab, helpdesk is the web browser-based help, including printable (PDF). Rudra Pratap is the author of Getting Started with MATLAB 7 ( avg rating, ratings, 5 reviews, published ), Getting Started with MATLAB (
You can do file navigation here. You also have 16 1. To see the options, click the right button of the mouse after selecting a file. You can run M-files, rename them, delete them, etc. Graphics window: The output of all graphics commands typed in the command window are flushed to the graphics or Figure window, a separate gray window with default white background color. The user can create as many figure windows as the system memory will allow.
Edit window: This is where you write, edit, create, and save your own programs in files called M-files. You can use any text editor to carry out these tasks. However, you can use your own editor by typing the standard file-editing command that you normally use on your system. The exclamation character prompts MATLAB to return the control temporarily to the local operating system, which executes the command following the!
For example, on Unix systems, typing! The commands 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 files and write output files see Section 4. 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 dimension statements are required for vectors or arrays. You can find the dimensions of an existing matrix or a vector with the size and length for vectors only commands.
Thus a and A are different variables. You can turn case sensitivity on and off with the casesen command. However, we do not recommend it. A semicolon at the end of a command suppresses the screen output, except for graphics and on-line help commands. Output format: Though computations inside MATLAB are performed using double precision, the appearance of floating point numbers on the screen is controlled by the output format in use.
There are several different screen output 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.
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 first 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 files: script files and function files see Section 4.
Some built-in functions are provided with source code in readable M-files so that they can be copied and modified. Mat-files are binary data-files, with a. Almost all commands work the same way. The only commands that differ are the ones that necessarily depend on the local operating system, 20 1.
The user interface how you interact with your computer , however, may vary a little from platform to platform. On Unix machines: Type matlab on the Unix prompt and hit return. If it is not, ask your system administrator. You can save all your work in this folder and access all your files 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 files is in a directory or folder immediately below the directory or folder in which the MATLAB application program is installed for PCs. If you need to store the files somewhere else, you might have to specify the path to the files 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 floppy disk , copy the file startup. You should also personalize the Startup file by editing it and adding a line, say, disp Hello Kelly, Welcome Aboard.
To open, write, and save M-files, use a text editor such as vi or emacs. Printing: On PCs: To print the contents of the current active window command, figure, or edit window , select Print For example, to print the file 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 files in the current directory, gives you options of opening, loading a. Use dir or ls at the command prompt to see if MATLAB lists your files or click on the Current Directory tab to the left of the command window to see the listing of files 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 overwriting an existing file while editing: You run your program by executing your M-file, do not like the result, edit the file, 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 file. 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 different than those given. Before You Start You need some information about the computer you are going to work on. In particular, find out: How to switch on the computer and get it started. How to log on and log off. Where you can write and save files hard drive or a floppy 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! Key features: Learn to add, multiply, and exponentiate numbers, use trig functions, and control screen output with format. Lesson Create and work with arrays, vectors in particular.
Key features: Learn to create, add, and multiply vectors, use sin and sqrt functions with vector arguments, and use linspace to create a vector. Lesson Plot simple graphs. Key features: Learn to plot, label, and print out a circle. Lesson Write and execute a script file.
Key features: Learn to write, save, and execute a script file that plots a unit circle. Lesson Write and execute a function file. Key features: Learn to write, save, and execute a function file that plots a circle of any specified radius.
Lesson Learn about file and directory navigation. Time Estimates: Lesson: 10 minutes Exercises: 30 minutes What you are going to learn: How to do simple arithmetic calculations. How to assign values to variables. How to suppress screen output. How to control the appearance of floating 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 unassigned expression is saved in the default variable ans.
You can also assign the value of an expression to a variable. Here are two examples. You can also quit by selecting quit from the file menu on Macs and PCs.
Figure 2. Arithmetic operations: Compute the following quantities: and compare with 1 1 1. Exponential and logarithms: The mathematical quantities e x, ln x, and log x are calculated with exp x , log x , and log10 x , respectively. Calculate the following quantities: e 3, ln e 3 , log 10 e 3 , and log 10 10 5. 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. 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 check the result by hand calculation?
Can you explain the difference between the two results? 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. Time Estimates: Lesson: 15 minutes Exercises: 45 minutes What you are going to learn: 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 arithmeticoperations on vectors. How to do array operations:. How to use trigonometricfunctions with array arguments.
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 Unix machines: Type matlab on the Unix prompt and hit re- turn. If it is not, ask your system administrator. 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.