Post on 14-Feb-2016
description
transcript
AL IMAM MOHAMMAD BIN SAUD ISLAMIC UNIVERSITY COLLEGE OF
SCIENCESDEPARTMENT OF MATHEMATICS
MATLAB 251 : MATH SOFTWARE
Introduction to MATLAB
MRS. ASRA SULTANA
INTRODUCTION TO MATLABBASICS ON MATLAB
Aims
1 .To present the software
2 .To introduce elementary operationsand functions.
3 .To manipulate 2D and 3D graphics.
4 .To introduce the notion of “files” and“programming.”
INTRODUCTION TO MATLAB
1 .First Steps in MATLAB
1.1 What is MATLAB
MATLAB (MATrix LABoratory) is a very powerful and interactivesoftware package optimized for scientific computation and, inManipulation. particular, matricesWith MATLAB we can do mathematics and computation, analyze data, develop algorithms, do simulation and modeling, produce graphical displays and graphical user interfaces.
MatLab Programming Language
External Interface (Mex-files)
Interface with C, Java and Fortran Programs
MATLAB
Built-in FunctionsUser-written Function
Graphics2-D Graphics3-D Graphics
Color and LightingAnimationAudio and Video
ComputationsLinear Algebra
Data AnalysisSignal Processing
Polynomials &InterpolationQuadrature
Solution of ODEs
*Image Processing
*Splines *Robust Control
*M-Analysis &synthesis *Optimization
*Financial AND MANY MORE
*Signal processing *Statistics
* Control System *System Identification
* Neural Networks* Communications
*Symbolic Mathematics
Toolboxes(Collections of specialized Function)
INTRODUCTION TO MATLAB
1 .MATLAB is an interpreted language (code is compiled each time it is run.
2 .MATLAB is easy to use (Mathematical operations) and has a complete documentation online .
3 .MATLAB is Excellent for manipulating large amounts of tabular data (arrays, matrices) in a consistent way .
4 .MATLAB has excellent visualization tools (plotting data and functions)
5 .MATLAB has Lots of built-in functions for applied mathematics such data analysis , interpolation, linear algebra, Fourier analysis…,
6 .MATLAB has many toolboxes (statistical, financial, symbolic,…)
7 .MATLAB is a good programming language.
8 .MATLAB allows to do numerical simulation based on numerical analysis algorithms.
9 .MATLAB allows interfacing with programs in other language (C, Fortran, …).
INTRODUCTION TO MATLAB
1.2 Short History ( http://en.wikipedia.org/wiki/MATLAB )
MATLAB was invented in the late 1970s by Cleve Moler, then chairman of the computer science department at the University of New Mexico. He designed it to give his students access to LINPACK and EISPACK without having to learn Fortran. It soon spread to other universities and found a strong audience within the applied mathematics community. Jack Little, an engineer, was exposed to it during a visit Moler made to Stanford University in 1983. Recognizing its commercial potential, he joined with Moler and Steve Bangert. They rewrote MATLAB in C and founded The Math Works in 1984 to continue its development. These rewritten libraries were known as JACKPAC.
MATLAB was first adopted by control design engineers, Little's specialty, but quickly spread to many other domains. It is now also used in education, in particular the teaching of linear algebra and numerical analysis, and is popular amongst scientists involved with image processing.
INTRODUCTION TO MATLAB
1.3 What is MATLAB useful references Full documentation available online in HTML and PDF
format. http://www.mathworks.com/access/helpdesk/help/helpdesk.html Many documents on the web (http://www.google.com.sa
)
Notice: there are many freeware/sharewares similar to MATLAB. For instance SCILAB
(http://www-rocq.inria.fr/scilab )
Read“Getting Started” section of the MATLAB manual
INTRODUCTION TO MATLAB
1.4 How to run MATLAB
To run MATLAB on a PC double-click on the MATLAB icon on the desktop.
To run MATLAB on a Unix system, Type MATLAB at the prompt.
When MATLAB starts, a window appears (MATLAB Desktop) containing three smaller windows of different size:1. The Command Window, 2. The Current Directory Window , and3. The Command History Window.
In the command window you should see a message:To get started, select MATLAB Help or Demos from the Help Menu.>>
INTRODUCTION TO MATLAB
>>
>>playbackdemo(‘desktop’) >>playbackdemo(‘historywindow’)
>>playbackdemo(‘currdirectory’)
>>playbackdemo(‘helpwindow’)
Command Windows
Curry directory
>>
MATLAB Prompt Tells that MATLAB is
ready for your Command
helpdesklookfor matrixLookfor diagonaliationLookfor diadonalLookfor spectrumLookfor seriesLas=3
home
Command HistoryMATLAB DESKTOP
INTRODUCTION TO MATLAB
Purpose Windows
Main windows, enter variables and commands, runs programs…,
Command Windows
Logs commands entered in the Command Window
Command History Window
Shows the files in the current repertory Current Directory Window
Contains output from the graphic commands
Figure Window
Creates and debugs script and functions files
Editor Window
Provides help information Help Window
Improve the performance of your M-files is using profiling tools
Profiler Window
Provides information about the variables that are used
Workspace Window
INTRODUCTION TO MATLAB
SIMULINKHELPOPEN FILES
NEWFILE
INTRODUCTION TO MATLAB
1.5 How to quit MATLAB
To end a MATLAB session type quit or exit at the MATLAB prompt. Click on the symbol on the upper right of the MATLAB window.
In the command window: To type commands the cursor must be placed after the command prompt (>>). Once the command typed, you have to press the “enter” key for executing the
command. You can type many commands on the same line separated between them by a
comma (,) .
X
INTRODUCTION TO MATLAB
>>
Command Window
39*4.4+5
ans = 176.6000 The MATLAB command
THE RESULT
INTRODUCTION TO MATLAB
1.6 Help me MATLAB!To get started, type one of these commands: help: Opens a MATLAB help at the prompt. helpwin: Opens a MATLAB help GUI helpdesk: Opens a MATLAB hypertext help
browser demo(s): Starts the MATLAB demonstrationYou can click on the icon on the MATLAB window
? You can learn how to use any MATLAB command by typing help followed by the name of the command, for example >>help sin.
You can also use the lookfor command, which searches the help entries for all MATLAB commands for a particular word.
you could type >> lookfor inverse. MATLAB responds with the names of the commands that have the searched word in the first line of the help entry. You can search the entire help entry for all MATLAB commands by typing >> lookfor –all inverse.
INTRODUCTION TO MATLAB
REMARK on the “HELP” command
For example, help solve will display documentation for solve.Unless you have a large monitor, the output of help solve will not fit in your MATLAB command window, and the beginning of the documentation will scroll quickly past the top of the screen. You can force MATLAB to display information one screenful at a time by typing more on.
You press the space bar to display the next screenful, or ENTER to display the next line; type help more for details. Typing more on affects all subsequent commands, until you type more off.