You are on page 1of 7

Chapter 1 MATLAB Advantages of MATLAB

Intro to MATLAB  MATLAB stands for  Easy to use


Matrix Laboratory  Platform Independence
 MATLAB programming for Engineering  Predefined Functions
introduces the MATLAB R2015b  Device- Independent Plotting
 http://ist.njit.edu/software  Graphical User Interface
 Release 2015a/2015b
 MATLAB Compiler

dr.dcd.h CS 101 /SJC 5th Edition 1 dr.dcd.h CS 101 /SJC 5th Edition 2 dr.dcd.h CS 101 /SJC 5th Edition 3

Disadvantages of MATLAB MATLAB Environment The MATLAB Desktop


 MATLAB is based on an interpreted language and it  In Windows or Apple operating systems  MATLAB uses several different windows to
may execute slower than compiled programs. click on the desktop icon display data, commands and results.
 A full copy of MATLAB is 5 to 10 times more
- comand window
expensive than a C/C++/Fortran compiler.
- toolstrip
- command history window
- document window
- figure window
 In Unix/MSDOS type
- workspace browser
MATLAB - current folder browser
- help browser
at the shell prompt
- path browser

 They are not necessarily all open at once.

dr.dcd.h CS 101 /SJC 5th Edition 4 dr.dcd.h CS 101 /SJC 5th Edition 5 dr.dcd.h CS 101 /SJC 5th Edition 6

1
The MATLAB Desktop2 The Command Window The Command Window2
 A user can enter interactive commands at
the command prompt (>>) in the
command window.
 A user can place a series of commands into
Command Window
a script file, and the entire file can be
executed by typing its name in the
command window.
 MATLAB script files are also known as M-
files, because they have a file extension of
“.m”.

dr.dcd.h CS 101 /SJC 5th Edition 7 dr.dcd.h CS 101 /SJC 5th Edition 8 dr.dcd.h CS 101 /SJC 5th Edition 9

The Toolstrip The Command History The Command History2


 The controls on the Toolstrip are organized  You can transfer commands from the
into related categories of functions, first by command history to the command window
tabs and then by goups.  Double click on a command
 The Quick Access Toolbar is a place where  Click and drag a command
the user can customize the interface.  Use arraw keys to select a command
 To delete commands from The History
Command History
 Select a command or commands
 Right-click with the mouse and select delete
 Or select clear to clear the entail history

dr.dcd.h CS 101 /SJC 5th Edition 10 dr.dcd.h CS 101 /SJC 5th Edition 11 dr.dcd.h CS 101 /SJC 5th Edition 12

2
The Document Window The Document Window2 The Document Window3
 It is also called Edit/Debug Window.
 An Edit Window is created when you create
a new M-file or open an existing one.
 There are several ways to open an editing
window:
 Click the New Script icon
 Click the New icon and then select Script
 Type edit from the command window

dr.dcd.h CS 101 /SJC 5th Edition 13 dr.dcd.h CS 101 /SJC 5th Edition 14 dr.dcd.h CS 101 /SJC 5th Edition 15

Figure Window Figure Window2 Docking & Undocking Windows


 The figure window is used to display  When a window is docked, it appears as a
graphics. pane within the MATLAB desktop.
 A figure can be a two- or three-dimensional
plot of data.
 When figures are created a new window
automatically opens.
 Figure window can be cleared by clf.

dr.dcd.h CS 101 /SJC 5th Edition 16 dr.dcd.h CS 101 /SJC 5th Edition 17 dr.dcd.h CS 101 /SJC 5th Edition 18

3
Docking & Undocking Windows2 The MATLAB Workspace The MATLAB Workspace2
 To undocking clicks the down-arrow icon to  A workspace is the collection of all the  The who andwhos commands.
the upper-right corner of a pane. variables and arrays that are defined within
the command window.
 This window is also called the Workspace
Browser.
 A list of variables and arrays in the currect
workspace can be generated with the who
or whos command.

dr.dcd.h CS 101 /SJC 5th Edition 19 dr.dcd.h CS 101 /SJC 5th Edition 20 dr.dcd.h CS 101 /SJC 5th Edition 21

The MATLAB Workspace3 Array Editor Array Editor2


 Use clear to delete a variable.  Double clicking on any variable in the
 Syntax: clear [variable-list] workspace will bring up the Array Editor.

dr.dcd.h CS 101 /SJC 5th Edition 22 dr.dcd.h CS 101 /SJC 5th Edition 23 dr.dcd.h CS 101 /SJC 5th Edition 24

4
Array Editor3 Current Folder Current Folder2
 Also called the current directory.  It allows the user to manipulate files
 It shows all the files in the selected folder. interactively.

dr.dcd.h CS 101 /SJC 5th Edition 25 dr.dcd.h CS 101 /SJC 5th Edition 26 dr.dcd.h CS 101 /SJC 5th Edition 27

Getting Help Getting Help2 Getting Help3


 Use the Help Browser.  To show the usage of a known command,  To search a command by keyword, using
using the help command. the lookfor command.

dr.dcd.h CS 101 /SJC 5th Edition 28 dr.dcd.h CS 101 /SJC 5th Edition 29 dr.dcd.h CS 101 /SJC 5th Edition 30

5
Useful Commands Useful Commands2 Useful Commands3
 who  Type demo in the command window.  To find out where a command is located,
 whos using the which command.
 clear [var_list]
 more on/off
 Ctrl-C (or ^C)
 clc (not cls)
 clf
 help command
 lookfor keyword
 demo
 which command

dr.dcd.h CS 101 /SJC 5th Edition 31 dr.dcd.h CS 101 /SJC 5th Edition 32 dr.dcd.h CS 101 /SJC 5th Edition 33

MATLAB Search Path MATLAB Search Path2 Red Flags


 If a name is typed at the system prompt,  Type path at the system prompt, the  Don’t do the followings intentionally:
the MATLAB interpreter attempts to find the MATLAB search path will be listed.  Do not use a variable with the same name as a
command as follows: system function or command.
 Checks as a variable in the workspace.  Do not create an M-file with the same name as a
 Checks as an M-file in the current folder. system function or command.
 Checks to see if it is an M-file in any directory
along the MATLAB search path.

dr.dcd.h CS 101 /SJC 5th Edition 34 dr.dcd.h CS 101 /SJC 5th Edition 35 dr.dcd.h CS 101 /SJC 5th Edition 36

6
Homework Assignment #1 How to Make Homework How to Make Homework2
 1.6 Exercises  Make sure your command window is under
 Page 24: 1.1, 1.3, 1.4, 1.8, 1.9, 10 format compact;
 This assignment is due by next week.  Enter the homework questions line-by-line;
 Late submission will be penalized.  Copy and paste the outputs including the
 Hand-written homework will not be commands into a word document and
accepted or graded. select the minimum spacing;
 Hand in a hardcopy of your homework, no  Save figures into image files and then
electronic submission will be accepted. insert them into your document. You may
need to change their sizes;
 Print your homework to a nearby printer.

dr.dcd.h CS 101 /SJC 5th Edition 37 dr.dcd.h CS 101 /SJC 5th Edition 38 dr.dcd.h CS 101 /SJC 5th Edition 39

How to Make Homework3 How to Make Homework4

dr.dcd.h CS 101 /SJC 5th Edition 40 dr.dcd.h CS 101 /SJC 5th Edition 41

You might also like