Академический Документы
Профессиональный Документы
Культура Документы
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 1 / 20
Introduction to MATLAB
Introduction to MATLAB
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 2 / 20
Introduction to MATLAB Main features
Main features
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 3 / 20
Introduction to MATLAB Toolboxes
Toolboxes
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 4 / 20
Introduction to MATLAB Symbolic calculations
Symbolic calculations
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 5 / 20
Basics of MATLAB MATLAB Windows
MATLAB Windows
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 6 / 20
Basics of MATLAB MATLAB Windows
Subwindows
Command Window:
This is the main window.
It is characterized by the MATLAB command prompt ().
When you launch MATLAB program, MATLAB puts you in this
window.
All commands are typed in this window at the MATLAB prompt.
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 7 / 20
Basics of MATLAB MATLAB Windows
Subwindows (Cont.)
Workspace pane:
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 8 / 20
Basics of MATLAB MATLAB Windows
Subwindows (Cont.)
Figure Window
The output of all graphics commands typed in the command window
are flushed to the graphics or figure window.
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 9 / 20
Basics of MATLAB MATLAB Windows
Subwindows (Cont.)
Editor 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 (e.g. Notepad in
MS Windows, vi in Linux).
However, MATLAB provides its own editor.
To get this editor type ‘edit’ on the MATLAB prompt and press the
‘ENTER’ key.
To get the Notepad type ‘! notepad’ and press ‘ENTER’ key.
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 10 / 20
Basics of MATLAB Input-output
Input-output
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 11 / 20
Basics of MATLAB Input-output
Input-output (Cont.)
Dimensioning:
Automatic in Matlab.
No dimension statements are required for vectors or arrays.
size and length (for vectors only) commands - returns the dimension
of a vector or a matrix.
Case sensitivity:
Differentiates between lowercase and uppercase letters.
E.g. a and A are different variables.
Most Matlab commands and built-in function calls are typed in
lowercase letters.
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 12 / 20
Basics of MATLAB Input-output
Input-output (Cont.)
Output display:
The output of the every command is displayed.
A semicolon (;) at the end of the command suppresses the screen
output (except graphics and on-line help commands).
Paged output - Type more on at the Matlab prompt to show one
screen of output at a time.
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 13 / 20
Basics of MATLAB Input-output
Input-output (Cont.)
Output format: There are different screen output formats. The following
table shows the printed value of 10π in seven different formats.
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 14 / 20
Basics of MATLAB Input-output
Input-output (Cont.)
Command history:
Matlab saves previously typed commands in a buffer.
These commands can be recalled with the up-arrow key (↑).
Previous commands can be recalled by typing the first few characters
and then pressing the ↑ key.
Alternatively you can double click on a command in the Command
History pane.
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 15 / 20
Basics of MATLAB File Types
File types
M-files
ASCII text files, with a .m extension.
Two types - script files and function files.
Most programs are saved as M-files.
All built-in functions are M-files.
MAT-files
Binary data files, with a .mat extension.
Created when you save data with the save command.
Can read only Matlab (with the load command).
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 16 / 20
Basics of MATLAB File Types
Fig-files
Binary figure files, with a .fig extension.
Use Save or Save As options from the File menu or saveas
command.
Opened with the open filename.fig.
P-files
Compiled M-files with a .p extension.
Created with the pcode command.
Can run the P-file without the source code (M-file).
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 17 / 20
Basics of MATLAB Working Directory
Working Directory
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 18 / 20
Basics of MATLAB General commands
General commands
On-line help
help - lists topics on which help is available
helpwin - opens the interactive help window
helpdesk - opens the web browser based help facility
help topic - provides help on topic
Workspace information
who - lists variables currently in the workspace
whos - lists variables currently in the workspace with their size
clear - clears the workspace, all variables are removed
clear x, y , z - clears only variables x, y and z
clear all - clears all variables and functions from workspace
mlock fun - locks fun so that clear cannot remove it
Dr. TGI Fernando () IM 512 3.0 (I) Mathematical Software September 16, 2011 19 / 20
Basics of MATLAB General commands