MATLAB Programming

From Wikibooks, the open-content textbooks collection

(Redirected from Matlab)
Jump to: navigation, search

MATLAB Programming

Chapter 1: A Tutorial Introduction

Chapter 2: Basic MATLAB Concepts

Saving and loading a MAT-file
MATLAB's Command Prompt
Basic Reading and Writing Data from a File

Chapter 3: Data Storage and Manipulation

Data Types and Operations on Point Values

Boolean and Rational
Strings
Portable Functions
Complex Numbers

Arrays and Matrices

What is an array?
Introduction to array operations
Vectors and basic vector operations
Struct Arrays
Cell Arrays
Sparse Matrices

Chapter 4: Graphics

Basic Graphics Commands
Annotating Plots

Chapter 5: M File Programming

Scripts
Comments
The Input Function
Control Flow
Loops and Branches
Error Messages
MATLAB Caveats
Debugging M Files

Chapter 6: Mathematical Manipulations

Linear Algebra

Simple matrix manipulation
More complicated matrix operations

Differential Equations

Ordinary Differential Equations
Partial Differential Equations

Chapter 7: More advanced I/O

Writing and Reading to a Serial Port
Writing to a USB Port

Chapter 8: Examples

Filtering
Controls
Phase vocoder

Chapter 9: Object-Oriented Programming

Struct arrays
MATLAB Classes

Chapter 10: An alternative to MATLAB: Octave

What is Octave ?
Octave/MATLAB differences

Chapter 11: Toolboxes

Symbolic Math Toolbox
GUIDE
Simulink
Psych Toolbox

edit this box

MATLAB is a programming language developed by The MathWorks. It started out as a matrix programming language where linear algebra programming was simple. It can be run both under interactive sessions as well as a batch job.

GNU Octave and LabVIEW MathScript are systems for numerical computations with an m-file script language that is mostly compatible with MATLAB. Both alternatives can replace MATLAB in many circumstances. While a good deal of the content of this book will also apply to both Octave and LabVIEW MathScript, it is not guaranteed to work in exactly the same manner. Differences and comparison between MATLAB and Octave are presented in Comparing Octave and MATLAB.

Contents

[edit] A Tutorial Introductions

[edit] Basic MATLAB Concepts

[edit] Saving and loading a MAT-fileImage:50%.png

[edit] The MATLAB Command PromptImage:50%.png

  • Calculator

[edit] Data Storage and Manipulation

[edit] Data Types and Operators on Point Values

[edit] Arrays and Matrices

[edit] Graphics

[edit] GraphicsImage:25%.png

[edit] Handle Graphics

What is a handle?
Figure handles
Axis handles
Other types of handles

[edit] Annotating PlotsImage:25%.png

[edit] M-file Programming

[edit] ScriptsImage:25%.png

[edit] Control FlowImage:75%.png

[edit] Error MessagesImage:75%.png

[edit] Debugging M FilesImage:50%.png

[edit] Numerical Manipulation

[edit] Linear Algebra

It is the Matrix laboratory after all.

  • Operations
  • Transpose
  • Systems of linear equations
  • Row reduced echelon form
  • Inverse
  • Coffactor, minor
  • Jacobian

[edit] Differential Equations

[edit] More advanced I/O

Different versions of MATLAB handle this differently. We will focus on versions 6.5 and 7.x, primarily on MATLAB 7.x since it is the latest. A note will appear when the procedure is different for ver. 6.

I hope this will be helpful to people who want to use MATLAB for something useful.

[edit] Writing and Reading to A Serial Port

[edit] Writing to a USB port

[edit] Examples

[edit] FilteringImage:25%.png

  • Moving Average
  • Alpha Beta
  • Kalman
  • PSD estimation
  • Entropy
  • Markov Processes
  • Queuing Theory

[edit] ControlsImage:25%.png

[edit] Phase vocoder

See "Phase vocoder and encoder in MATLAB" for an example phase vocoder and the corresponding sound sample encoder in MATLAB.

[edit] Object Oriented Programming

MATLAB as well as Octave have object oriented capabilities. Yet, technically it is not fully an object oriented language.

An Object Oriented Language(OOL) has three components: 1. Polymorphism 2. Inheritance 3. Encapsulation

Octave can be extended by adding new objects. Those objects can overload the operators like e.g. assignment, slicing, comparison.

While in MATLAB, this can be done with m-script, in Octave new objects are implemented as C++ classes. A simple example of how objects can be added to Octave can be found here.

[edit] Struct arraysImage:25%.png

[edit] MATLAB classesImage:00%.png

[edit] An alternative to MATLAB: Octave

[edit] What is Octave ?

A short presentation of Octave and its history.

[edit] Differences between Octave and MATLAB

The most important differences between Octave and MATLAB that anyone willing to use Octave instead of MATLAB should be aware of.

[edit] Toolboxes and Extensions

The toolboxes are pretty good if you can afford them. In version 7 there are a lot of toolboxes.

[edit] Symbolic ToolboxImage:75%.png

[edit] Image Processing ToolboxImage:00%.png

[edit] MATLAB CompilerImage:00%.png

[edit] Legacy Toolboxes

  • GUIDEImage:00%.png allows the creation of interactive user interfaces.
  • SimulinkImage:00%.png is for modeling, simulating and analysing systems.
  • PsychtoolboxImage:00%.png is a set of tools that aid in vision research.
  • Distributed computing- The distributed computing toolbox is a set of tools that aid in distributing models over a cluster.
  • Optimization- The optimization toolbox includes various algorithms for minimization.

[edit] References

[edit] External links

[edit] Other Wikibooks

A number of other wikibooks use MATLAB to teach their subjects. The following wikibooks make use of MATLAB:

[edit] Organization

Personal tools
Create a book