YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.

A Brief Introduction to MATLAB

Shibaji Shome and Rob MacLeod

CVRTI

University of Utah

Page 2: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.

What is MATLAB?

• MATrix LABoratory (The MathWorks,Inc)

• Easy access to matrix computation software

• Scientific computing and Visualization package

• Arrays/matrices are at the heart of MATLAB

• All data are stored as arrays

Page 3: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.

Ok, but what is MATLAB?

1) Concept of Workspace

2) In-Built functions - commands

3) M-scripts

4) User-defined functions

Page 4: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.

Workspace

• Workspace initializes on launch

• Front end to MATLAB

• Access MATLAB functions

• Manage variables

Page 5: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.

Workspace

• Start MATLAB: Type “matlab” at system prompt / click application icon

• On starting MATLAB:

* Matlab command window - your workspace

* Matlab command prompt - interact

Page 6: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.

Commands

• In built functions• Manage environment, variables, commands,

functions• Manage files, interact with the OS• Perform computations, etc

Page 7: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.
Page 8: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.

M-Files or scripts

• Execute a batch of commands in a sequential manner.

• Compartmentalize your commands, organize them into a M-file.

• All variables and results are global ie can be accessed from the workspace.

• Name your m-file (with a .m extension), execute at command prompt by just typing the filename.

Page 9: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.
Page 10: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.

Functions• Essentially user defined commands.• Accept inputs from the workspace or another

function/command.• Output to workspace or output becomes input to another

command/function.• Encapsulation of variables.• Only the outputs of a function are global.• A function can call other functions within it, make calls to

itself recursively.• Structures your program, makes it more flexible,

manageable and easy to debug.

Page 11: A Brief Introduction to MATLAB Shibaji Shome and Rob MacLeod CVRTI University of Utah.

Related Documents