MATLAB Examples

Step through and execute this script cell-by-cell to verify a cell array implementation of the List Abstract Data Type (ADT).

Example 1: Bendat and piersol, Random data, 2010, page 99 Example 4.4

We illustrate how to find colorings of graphs and display the results.

Only scalar variables need apply. Matrices and vectors would not be terribly difficult to implement, but I've not done so.

We demonstrate how to split the vertex set of a graph into two parts using the split method. The goal is to separate the vertices of the graph into two natural clusters. The splitting is based on

This is a parameter sweep study of a 2nd order ODE system.

The function NATSORT sorts a cell array of strings, taking into account any number values within the strings. This is known as a "natural order sort" or an "alphanumeric sort". Note that

We specify a finite group by giving a list of its generators. The generators are a cell array of permutations of a common ground set.

We demonstrate how to find a minimum dominating set in a graph. This requires Matlab's Optimization Toolbox. We illustrate this using Petersen's graph and a grid graph.

This demo illustrates how you would set up and solve an optimization problem (constrained non-linear minimization).

This demo illustrates a simple approach to provide taxonomy annotation of BLAST hits. It requires the taxonomy information included in the files gi_taxid_prot.dmp and nodes.dmp, which

Matgraph provides two functions for finding spanning trees:

The function ROUND60063 rounds the input numeric values to values from the IEC 60063 "Preferred Numbers" series. Most importantly ROUND60063 simulates the tolerance range of electronic

The function NUM2SIP converts a numeric scalar to a string containing the number value with a metric prefix, for example 1000 -> '1 k'. Optional arguments control the number of digits, select

The function WORDS2NUM converts a string (with a number given in English words) into a numeric value, e.g. 'one thousand and twenty-four' -> 1024. Optional arguments control many string

Solves a 2nd order wave equation: utt = uxx + uyy, with u = 0 on the boundaries. It uses a 2nd order central finite difference in time and a Chebyshev spectral method in space (using FFT). The code

The errorshade function plots a shaded region to indicate gaussian uncertainty. This function works by generating an RGB image of a specified color, and setting transparency of the RGB

Step through and execute this script cell-by-cell to verify the Singleton Desgin Pattern implementation in MATLAB.

This document demonstrates the usage of GENCODE, GENCODE_RVALUE and GENCODE_SUBSTRUCT to show and modify the contents of complicated MATLAB variables.

We show that the the Ramsey number R(4) is greater than 17 by presenting a graph with 17 vertices that has clique and independence numbers equal to three. The Matgraph alpha and omega functions

The function SIP2NUM converts a string containing a number with a metric prefix into a numeric value, for example '1 k' -> 1000. The function is based on REGEXP, and can detect and convert

The nanimresize function resizes an image using the Image Processing toolbox function imresize, but first fills NaNs to prevent missing data along NaN boundaries.

Looking at Spring Damper System and comparing the results from the ODE45, ODE23, ODE15s solvers with the analytical solution.

We illustrate the use of bipmatch to find maximum matchings in bipartite graphs.

The function NUM2WORDS converts a numeric scalar into a string with the number value given in English words, e.g. 1024 -> 'one thousand and twenty-four'. Optional arguments control the

The function NATSORTROWS sorts the rows of a cell array of strings, taking into account any number values within the strings. This is known as a "natural order sort" or an "alphanumeric sort".

We illustrate how to find a Hamiltonian cycle in a graph, convert that cycle into a subgraph, and then display the results.

Write a script that tests a function that you create. The example function computes the angles of a right triangle, and you create a script-based unit test to test the function.

The euler_trail function finds Eulerian trails and tours in graphs.

We show how to determine if two graphs are isomorphic and, if so, how to find the permutation that transforms one into the other.

This finite element thermal analysis (FEA) examines the heat tolerance for a robotics component of a commercial youBot.

The imagescn behaves just like imagesc, but makes NaNs transparent, sets axis to xy if xdata and ydata are included, and has more error checking than imagesc.

Code File

This function prints some quick statistics about a variable in the command window.

The Matgraph package includes a permutation data type. Here we illustrate some of the features of that type.

Define two int64 arrays

This function formats long strings into wrapped text of specified width.

Many Matgraph functions work with partitions. For example, the color function returns a partition of the vertex set and bipmatch takes a partition as one of its arguments. Matgraph provides

Step through and execute this script cell-by-cell to verify the iterator for a CellArrayList.

Adaptively evaluate a function on a given range. There are different methods which can be used for choosing where to add new data points. The default method provided by 'adaptive.m' is to add

Write a script-based test that uses local functions as helper functions. The example function approximates the sine and cosine of an angle. The script-based test checks the approximation

Anonymous functions require that you explicitly specify the input arguments as you would for a standard function, separating multiple inputs with commas. For example, this function

The following is an example of how to use the Live Editor to create an interactive narrative. Create an interactive narrative to tell a story with computations that you have used to solve a

The following is an example of how to use the Live Editor to accelerate exploratory programming. This example demonstates how you can use the Live Editor to:

MATLAB ® scripts, including live scripts, can contain code to define functions. These functions are called local functions.

Request specific outputs from a function.

Test a function that you create by writing a live script, 'TestRightTriLiveScriptExample.mlx' . The example function computes the angles of a right triangle, and you create a

Anonymous functions allow you to define a function without creating a program file, as long as the function consists of a single statement. A common application of anonymous functions is to

Use the output of one MATLAB® function as an input to another. This ability to specify a function's output as an input of another function serves a wide variety of purposes. Here we illustrate

Use nested functions to easily share data, as well as for creating customized functions.

The following is an example of how to use live scripts in the classroom. This example shows how to:

Is an introduction to the Live Editor. In the Live Editor, you can create live scripts that show output together with the code that produced it. Add formatted text, equations, images, and

Define functions at the command line with anonymous functions.

Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a location from the following list:

See all countries