MATLAB Examples

Find the maximum value of a single variable in a data set using mapreduce. It demonstrates the simplest use of mapreduce since there is only one key and minimal computation.

Use mapreduce to carry out simple logistic regression using a single predictor. It demonstrates chaining multiple mapreduce calls to carry out an iterative algorithm. Since each

Compute the mean of a single variable in a data set using mapreduce. It demonstrates a simple use of mapreduce with one key, minimal computation, and an intermediate state (accumulating

Visualize patterns in a large data set without having to load all of the observations into memory simultaneously. It demonstrates how to compute lower volume summaries of the data that are

Compute the mean by group in a data set using mapreduce. It demonstrates how to do computations on subgroups of data.

Extract a subset of a large data set.

Compute the mean and covariance for several variables in a large data set using mapreduce. It then uses the covariance to perform several follow-up calculations that do not require another

Compute summary statistics organized by group using mapreduce. It demonstrates the use of an anonymous function to pass an extra grouping parameter to a parameterized map function. This

Compute a tall skinny QR (TSQR) factorization using mapreduce. It demonstrates how to chain mapreduce calls to perform multiple iterations of factorizations, and uses the info argument of

Use high-level MATLAB® functions to import the sample CDF file, example.cdf . High-level functions provide a simpler interface to accessing CDF files.

Use ImageDatastore and mapreduce to find images with maximum hue, saturation and brightness values in an image collection.

Use tall arrays to work with big data in MATLAB®. You can use tall arrays to perform a variety of calculations on different types of data that does not fit in memory. These include basic

Use the findgroups and splitapply functions to calculate grouped statistics of a tall timetable containing power outage data. findgroups and splitapply enable you to break up tall

Create a datastore for key-value pair data in a MAT-file that is the output of mapreduce . Then, the example shows how to read all the data in the datastore and sort it. This example assumes that

Create text files, including combinations of numeric and character data and nonrectangular files, using the low-level fprintf function.

Use low-level functions to read data from a CDF file. The MATLAB® low-level CDF functions correspond to routines in the CDF C API library. To use the MATLAB CDF low-level functions

Create a datastore for a collection of images, read the image files, and find the images with the maximum average hue, saturation, and brightness (HSV). For a similar example on image

Import comma-separated numeric data from a text file. Create a sample file, read all the data in the file, and then read only a subset starting from a specified location.

Create two different memory maps, and then read from each of the maps using the appropriate syntax. Then, it shows how to modify map properties and analyze your data.

To export a table in the workspace to a Microsoft® Excel® spreadsheet file, use the writetable function. You can export data from the workspace to any worksheet in the file, and to any location

Use low-level functions to write data to a NetCDF file. The MATLAB® low-level functions provide access to the routines in the NetCDF C library. MATLAB groups the functions into a package,

Create a datastore for a large text file containing tabular data, and then read and process the data one chunk at a time or one file at a time.

Access parts of variables from a MAT-file dynamically. This is useful when working with MAT-files whose variables names are not always known.

Export data to a CDF file using MATLAB® CDF low-level functions. The MATLAB functions correspond to routines in the CDF C API library.

Overwrite a portion of an existing binary file and append values to the file.

Perform simple linear regression using the accidents dataset. The example also shows you how to calculate the coefficient of determination R^2 to evaluate the regressions. The accidents

Write MATLAB® arrays to a Scientific Data Set in an HDF4 file.

Read data from a Scientific Data Set in an HDF4 file, using the functions in the matlat.io.hdf4.sd package. In HDF4 terminology, the numeric arrays stored in HDF4 files are called data sets.

Split data from the patients.mat data file into groups. Then it shows how to calculate mean weights and body mass indices, and variances in blood pressure readings, for the groups of

Append values to an existing text file, rewrite the entire file, and overwrite only a portion of the file.

Write and read complex numbers in binary files.

Remove a linear trend from daily closing stock prices to emphasize the price fluctuations about the overall increase. If the data does have a trend, detrending it forces its mean to zero and

Load, modify, and save part of a variable in an existing MAT-file using the matfile function.

Create a new NetCDF file that contains the variable, dimension, and group definitions of an existing file, but uses a different format.

Import numeric data delimited by any single character using the dlmread function. Create a sample file, read the entire file, and then read a subset of the file starting at the specified

Use histogram and histogram2 to analyze and visualize data contained in a tall array.

Extract date information from a CDF epoch object. CDF represents time differently than MATLAB®. CDF represents date and time as the number of milliseconds since 1-Jan-0000. This is called

You can export tabular data from MATLAB® workspace into a text file using the writetable function. Create a sample table, write the table to text file, and then write the table to text file with

Use the fwrite function to export a stream of binary data to a file.

View the codec associated with a video file, using the mmfileinfo function.

Use the MATLAB® HDF5 low-level functions to write a data set to an HDF5 file and then read the data set from the file.

Get information about the dimensions, variables, and attributes in a NetCDF file using MATLAB low-level functions in the netcdf package. To use these functions effectively, you should be

Convert between video files and sequences of image files using VideoReader and VideoWriter.

Use the datastore and mapreduce functions to process a large amount of file-based data. The MapReduce algorithm is a mainstay of many modern "big data" applications. This example operates

Read numeric data organized in blocks in a text file. Each block within the file can have a different format. You can read all the blocks as cell arrays, one block at a time, using textscan .

Several different ways you can visualize tall arrays.

Use an FTP object to connect to an FTP server and perform remote file operations. To perform any file operation on an FTP server, follow these steps:

Data smoothing refers to techniques for eliminating unwanted noise or behaviors in data, while outlier detection identifies data points that are significantly different from the rest of

Use the readtable function to import mixed text and numeric data into a table, specify the data types for the variables, and then append a new variable to the table.

The best way to represent spreadsheet data in MATLAB® is in a table, which can store a mix of numeric and text data, as well as variable and row names. You can read data into tables interactively

Import formatted dates and times (such as '01/01/01' or '12:30:45' ) from column oriented tabular data in three ways.

You can export a numerical array to a text file using dlmwrite . The dlmwrite function, enables you to specify the delimiter and the numerical precision of data in the file.

You can export a cell array from MATLAB® workspace into a text file in one of these ways:

When your data is stored across multiple text files, you can use tabularTextDatastore to manage and import the data. This example shows how to use tabularTextDatastore to read the data from

When you have data stored across multiple spreadsheet files, use spreadsheetDatastore to manage and import the data. After creating the datastore, you can read all the data from the

Reads a block of mixed text and numeric data from a text file, and then imports the block of data into a table or a cell array.

Choose a web site 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 web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Contact your local office