MATLAB Examples

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

The following document was built from posts written for the blog "Loren on the Art of MATLAB". The ideas presented below in anonymous functions have been written as .m files so that they might

This example was authored by the MathWorks community.

QRcode_gen can generate QR-Codes based on the zxing libraries (http://github.com/zxing). For this purpose it will import all necessary jar files on the fly from a maven repository server

We will now look at defining methods in the class definition file which are the operations that we can carry out with the class.

Pack and unpack data using the provided packData and unpackData functions

This is the most useful diagram for visualizing the contest. It shows the dramatic improvements that occur over time. Each passing entry is a dot, with its submission time on the x-axis and

Matlab implementation of Flickr-compatible OAuth

This example shows how to generate code from packData and unpackData

Compute normalized probability density function from characteristic function. Part of the CFH Toolbox.

Compute call option prices from characteristic function. Part of the CFH Toolbox.

This contribution presents a small tool to trace calls to methods and functions. There was no tracing tool for Matlab to find on the Internet and still isn't?

Jonas Almeida, April 2010

This script uses the class definition TestClass to create instances of TestClass and to clone its instances.

Returns the characteristic function evaluation of commonly encountered models in finance. Part of the CFH Toolbox.

Library of transforms (moment generating functions) of commonly ecountered jump distributions in finance. Part of the CFH Toolbox.

Let's say that the sensor array data set was very large, taking up several GB. Althought you may modfiy it and you would never need to make a copy of it. In this case a handle class implementation

To monitor an object you first need to add an event to the class definition of the object, such as in this example. (see ev.m). Here we add an event called SavedData to this class which denotes

Compute spread option prices on the difference between to assets' price levels. Part of the CFH Toolbox.

Compute bond prices for an AJD process. Part of the CFH Toolbox.

This presentation proceeds in stages, each version an extension of its predecessor (bootstrapping). The development stops well short of an industrial compiler but that is not because of

Write a unit test for a MATLAB® function, quadraticSolver.m.

We are going to create a class to describe the sensor array data set. First we will look at specifying the properties. You define a class in MATLAB with a class definition file.

Returns conditional expectations given a charcteristic function. Part of the CFH Toolbox.

You can create a customized class by specifying that your class inherits from another class.

Returns the extended characteristic function evaluation of a parameterized Affine Jump-Diffusion (AJD) process. Part of the CFH Toolbox.

Compute extended transform bond prices for an AJD process. Part of the CFH Toolbox.

Returns the characteristic function evaluation of a parameterized Affine Jump-Diffusion (AJD) process. Part of the CFH Toolbox.

Test sads class using separate methods (see +valueSeparateMethods folder)

QRcode_gen can generate QR-Codes based on the zxing libraries ( http://github.com/zxing ). For this purpose it will import all necessary jar files on the fly from a maven repository server

The limitation of 52 phrase names and the ursurpation 1/2 of them for Kleene*, and 8 of them for built-in character classes, is the last of the tasks set in Chapter 1. It would be nice to play the

The Grammar Executing Machine principle has been demonstrated in Chapter 1. The version 0 driver gem0.m and MEX files iog0.c and iog0.h provide no-frills code that runs on the edge of

Treatment of whitespace and character classes.

All compilers have to connect to the underlying hardware. That in turn requires knowing where the bits need to go. It isn't always fun, but that is what compiler writers do.

Up until now the emphasis has been on choosing new capabilities expressed first as bootstraps, then building the capabilities into GEM itself. The final built-in capability of GEM added

Retrieve it using lasterr. Note the additional line in the error message.

Returns the no arbitrage drift coefficients of an AJD process. Part of the CFH Toolbox.

Ïnteger weights of items

If hot=true, the database structure is modified as needed. e.g, when you get a table with d.table('tablex'), tablex is automatically created. Similarly, when you insert entries into

This is the first entry in the Data Visualization contest. It contains the data set contest_data

Write a unit test for a couple of MATLAB® figure axes properties using fresh fixtures and file fixtures.

These examples show how to use Python® language functions and modules within MATLAB®. The first example calls a text-formatting module from the Python standard library. The second example

When unit testing, you are often interested in testing a portion of a complete system, isolated from the components it depends on. To test a portion of the system, we can substitute mock

Create a tuple variable to pass to a Python® function.

Use a System.String object in a MATLAB® function.

Set a static property using the NET.setStaticProperty function.

Convert a Python® list of numeric values into a MATLAB® array of double.

Create a Python® tuple variable with a single element. A tuple with one element has a trailing comma.

Update a Python® list of folder names using the append method.

Access an element of a Python® list variable containing list elements.

Call the Python math.fsum function, which sums the floating-point values in an interable input argument.

Display HTML text from the first paragraph on the www.mathworks.com website.

Display elements of a Python® list.

Use the Python® path separator character (;). In MATLAB®, a Python character is a py.str variable.

Get and set values in a dictionary.

Display the last element in a Python® list variable. The example compares indexing into a MATLAB® cell array with indexing into a Python list.

Create a dict variable to pass to a Python® function.

Change the cursor icon in an Excel® spreadsheet.

Display elements in a tuple.

Pass the backslash control character (\) as a Python® str type.

Display the first character of a Python® str variable. The example compares indexing into a MATLAB® character vector with indexing into the Python variable.

Change a value in a dict variable using the Python® update method.

Create a list variable to pass to a Python® function.

Create a .NET jagged array of System.Double using the NET.createArray function.

Change the height of a row, defined by a Range object, in a spreadsheet.

Use an incremental step in indexing.

Evaluate the expression x+y in Python®. To evaluate an expression, pass a Python dict value for the globals namespace parameter.

Use Python® numbers in MATLAB®. The trigonometry functions in the math module return Python float types.

Analyze the information returned by a test runner created from the SolverTest test case.

Pass a MATLAB structure to the function, addStructFields .

Create a pointer to a subset of a MATLAB vector X . The new pointer is valid only as long as the original pointer exists.

Construct and pass a pointer to C function multDoubleRef .

Pass a MATLAB character array str to a C function, stringToUpper .

Pass data stored columnwise in a MATLAB array to a C function that assumes a row-by-column format.

How a C function changes the dimensions of a MATLAB array, and how to restore its shape.

Pass a MATLAB structure to a C library function, addStructByRef . When you pass the structure, MATLAB automatically converts the field types, but MATLAB also makes a copy of the fields.

Pass a multilevel pointer to a C function.

Create a MATLAB® cell array of character vectors, mlStringArray , from the output of the getListOfStrings function.

How calling the addStructByRef function with a pointer modifies the fields in the input argument.

Display information about and modify a libstruct object, c_struct .

Use pointer arithmetic to access elements of a structure. The example creates a MATLAB structure, based on the c_struct definition in the shrlibsample.h header file.

Add a plugin to the test runner. The matlab.unittest.plugins.TestRunProgressPlugin displays progress messages about a test case. This plugin is part of the matlab.unittest package.

Preconvert structure sm to c_struct before calling addStructFields . If you repeatedly pass sm to functions, preconverting eliminates the processing time required by MATLAB to

Pass enumeration values to the readEnum function in the shrlibsample library. Load the library.

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