MATLAB Examples

F. Moisy, 9 july 2008. University Paris Sud.

Utility from File Exchange

Demonstrates building and validating a short term electricity load forecasting model with MATLAB. The models take into account multiple sources of information including temperatures

Copyright 2017 The MathWorks, Inc.

Demonstrates building and validating a short term electricity price forecasting model with MATLAB using Neural Networks. The models take into account multiple sources of information

本プログラムでは、MATLAB上でSegNetを構築・学習し、 学習済みネットワークを評価するところまでのワークフローを試行します。 画像データは血液塗抹標本画像を利用し、写っている寄生虫の部分、赤血球の部分と それ以外の領域の3クラスに分類することを目的とします。 画像データは米国CDC DPDx Parasite Image

This examples illustrates how to perform a FORM analysis on a discrete (0 or 1) failure response. In the example we'll compare a traditional Monte Carlo method with FORM. This example is was

This example was authored by the MathWorks community.

本プログラムでは、MATLAB上でFCN-AlexNetを構築・学習し、 学習済みネットワークを評価するところまでのワークフローを試行します。 画像データはCamVidデータセットを利用します。詳細についてはReference[1]をご覧ください。

Gaussian fit using the least-squared solution in presence of known covariance

Number of rows in healthy file must be the same as the number of rows in disease file. This reflects the fact that both must have measured the same number of quantities (genes, compounds, bugs,

This is the third script of 4 in the Natural Gas Storage Valuation case study. In this script, we calibrate a forward curve model to historical and options-derived forward curve data. The

And Generate Code to Run Algorithms on Raspberry Pi

Fit a polynomial curve to a set of data points using the polyfit function. You can use polyfit to find the coefficients of a polynomial that fits a set of data in a least-squares sense using the

Demonstrates computing Value-at-Risk and Conditional Value-at-Risk (expected shortfall) for a portfolio using multivariate copula simulation with fat-tailed marginal

Simulates the movements of a swarm to minimize the objective function

Coorous Mohtadi, MathWorks, 2012

This script aims at demonstrating the capabilities and the syntax of simpletracker.m, a MATLAB function dedicated to tracking.

This document explains how to use the state space MPC function which using input increment.

Animates the vibration of a membrane, captures a series of screen shots, and saves the animation as a GIF image file.

In this demo, we use optimization to find optimal bang-coast-bang acceleration basis functions. Acceleration function is calculated to minimize swing of payload. Dynamic equations used

Now that we can generate a forecast for future electricity demand, the next question is what actions should we take based on that forecast? One area of interest is how to operate a combination

David Young

We will derive the equations of motion for an overhead gantry crane system. We simplify the gantry cane system as just a payload (pendulum) on a movable support, as illustrated in the diagram

This script demonstrates testing a simple technical indicator strategy and backtesting to optimize its parameters

This script contains the examples shown in the webinar titled Optimization Tips and Tricks: Getting Started using Optimization with MATLAB presented live on 21 August 2008. To view the

This live script covers the concept of limits, the main properties and techniques for calculating them.

This script demonstrates using the included Talbot and Euler algorithms for numerical approximations of the inverse Laplace transform. The examples cover functions with known inverses

Registers two images (2-D rigid translation) within a fraction of a pixel specified by the user. Instead of computing a zero-padded FFT (fast Fourier transform), this code uses selective

Non-negative least-squares solves the following problem:

Medical image segmentation using texture analysis

A computer vision system which takes an uncontrolled image of a sudoku puzzles, identifies its location, reads the puzzle, and solves it.

This live script covers the concepts of antiderivatives and integrals.

This live script covers the concept of continuity using limits.

Author: Timon Viola

This script reads in an image file and then attempts to find a green object in the image. It is designed to find one green ball and highlight that ball on the original image

How many of you have successfully solved a Rubik's Cube® before? How long did you take to solve a cube that your friend scrambled? I have been able to successfully solve a Rubik's Cube, but have

本プログラムでは、MATLAB上でCNNを構築・学習し、学習済みネットワークを評価するところまでの ワークフローを試行します。また、学習したネットワークを実装するために、CUDA C++コードを生成し、 既存のコードと統合して.exeを作成します。

These prototype MATLAB functions create and plot graphs from images based on neighbor relationships between pixels. You must have MATLAB R2015b to use them.

In this demo, we use regression trees to predict the fuel economy of vehicles.

Igor Podlubny (a), Tomas Skovranek (a), Blas M. Vinagre Jara (b)

Define a function that visualizes the results of bfsearch and dfsearch by highlighting the nodes and edges of a graph.

This is the first script of 4 in the Natural Gas Storage Valuation case study. In this script, we import a data set of historical futures prices for natural gas, pre-process them and compute

From: "Using Statistics and Optimization to Support Design Activities" Webinar, July 21, 2009.

Copyright (c) 2008 Gabriel Peyre

This is the fourth script of 4 in the Natural Gas Storage Valuation case study. In this script, we value the storage facility using the rolling intrinsic optimization method. To do so, we

Copyright 2018 The MathWorks, Inc.

This demo was adapted from a 2009 digest article: Improving Optimization Performance with Parallel Computing

Matlab_Abaqus_10_Bar_Truss is a Matlab source code which is used to find the optimum design of a 10-bar truss, described in section 2. It is developed by George Papazafeiropoulos

Control vector parameterization, also known as direct sequential method, is one of the direct optimization methods for solving optimal control problems. The basic idea of direct

By Jarek Tuszynski

This live script reviews functions, function notation and necessary properties.

Abstract:

Beta is vector of regressors P(beta|D) ~ N(beta| mu, lambda) mu = lambda * X{transpose} * big_sigma^(-1) * Y lambda = (X{transpose} * inv(sigma) * X + inv(big_omega))^{-1}

La Toolbox concernant le calcul symbolique dans Matlab est un outil très intéressant dans différents domaines de la physique en particulier. Pour illustrer son utilisation, nous allons

The Dragon Curve is a fractal that was made famous in Jurassic Park , a novel by Michael Crichton.

X_s=sym('x_s'); y_s= 2/(1+exp(-2*x_s))-1; %Eqn of hyperbolic tangent, from apply_transfer dy_s=diff(y_s,x_s); % Put into apply_transfer of modified file ddy_s=diff(dy_s,x_s); %

Matlab_Abaqus_25_Bar_Truss is a Matlab source code which is used to find the optimum design of a 25-bar truss, described in section 2. It is developed by George Papazafeiropoulos

The Riemann problem of 1D elastodynamics

The second term

This demo shows index replication where the goal is to find a portfolio of stocks that replicates performance of the entire S&P 500. The data used is S&P 500 returns from Aug 21, 2009 to Aug 20,

Copyright 2016 The MathWorks, Inc.

This is the second script of 4 in the Natural Gas Storage Valuation case study. This script prices a natural gas storage contract using the Intrinsic & Spread Option valuation methods. Please

Introducing fplot for disco...

Demonstrates an alternate model for building relationships between historical weather and load data to build and test a short term load forecasting. The model used is a set of aggregated

By F. Pedroche, M. Rebollo, C. Carrascosa and A. Palomares (2012) Universitat Politècnica de València (Spain)

By Ken Deeley, MathWorks

Batchpleas is a wrapper for lsqnonlin, allowing it to solve many small problems (all with the same parameterization) in one batched, partitioned nonlinear least squares estimation. This

Haftka, R. T. and Z. Gurdal (1992), Elements of Structural Optimization, Kluwer Academic Publishers

How to use Cell Mode in the MATLAB Editor.

Find the cross-sections of the members of the 25-bar truss so that its weight is minimized and the constraints are satisfied. For more information please see the Documentation of

This live script covers the concept of derivatives and how to calculate them.

Model, configure, generate AUTOSAR compliant code and export xml files using Simulink® and Embedded Coder®. The Vehicle Speed and Odometer calculations example demonstrates this

This is a simple Evolutionary Multiobjective Optimization problem (two objectives).

Copyright 2015-2016 The MathWorks, Inc.Published with MATLAB® R2016a

Differintegral of the identity function using Fourier series representation

State Space MPC code.

This script provides a demo for th function linstretchrgb. This script is used to perform linear contrast stretching of a % 3-band image(FCC). The script is designed as a part of the laboraory

Use linear programming and mixed-integer linear programming techniques to determine which bonds should be purchased to cover a given a cash flow in order to meet payout obligations, say for

This file describes the development of a failure boundary identication algorithm shown in "Using Statistics and Optimization to Support Design Activities" Webinar, July 21, 2009.

Hock W., Schittkowski K. (1981): Test Examples for Nonlinear Programming Codes, Willi Hock, Klaus Schittkowski, Springer, Lecture Notes in Economics and Mathematical Systems, Vol. 187

Svanberg, Krister, "The Method of Moving Asymptotes--A New Method for Structural Optimization," Intl. J. Num. Meth. Vol. 24, 1987, pp. 359-373.

A brief introduction to directional lapped orthogonal transforms

The L8read function reads full-resolution Level 1 Landsat 8 images and has the ability to subset the image before loading.

Computation of a limit usually involves a function that we cannot evaluate at the point of interest. It is often due to a singularity at the point of interest that we cannot evaluate the

How might one best compute the limit of a function at a specific point using numerical techniques? Since we need to compute a limit, the function will generally be singular in some fashion at

A MATLAB implementation of the Faddeev-Leverrier algorithm to compute the coefficients of the characteristic polynomial of a given matrix and to get the inverse of the matrix without extra

Program Apple iOS app with MATLAB language.

Format. The user can specify any number of digits to be carried, while doing a variety of different numerical computations on these numbers. Not all MATLAB operators are defined, as my main

The Dragon Curve is a fractal that was made famous in Jurassic Park, a novel by Michael Crichton.

Called functions explicitlly shown in this function body: denoised_unwrap, phase_wrap.

This demo is an example of performing data mining on historical fuel economy data. We have data from various cars built from year 2000 up to 2012.

This MATLAB live script analyzes the dynamics of two bodies attracted by the force of gravity using Symbolic Math Toolbox, highlighting many of its key features.

This script demonstrates how to use the Optimization Toolbox to simulate electromagnetic shielding by a Faraday Cage .

This function creates a flattened image with overlayed mask (with transparency). The mask is applied with a specified color and transparency over the original image, and the resulting

Display a table of values for a gray-scale image.

Differintegral of a cubic polynomial using Fourier series representation

Plot function is optional argument first argument is a list of the population (columns are agents) second argument is a style for different phases: 'b.' for moving, 'r+' for cluster,'c*' for

Find the cross-sections of the members of the 10-bar truss so that its weight is minimized and the constraints are satisfied. For more information please see the Documentation of

Customer provided this example where he was puzzled why fmincon had a hard time finding the mimimum value.

Note that if we look at the points that are very close to z0, then the polynomial may have strange coefficients.

Script to Run Gary Vanderplaats cantilever Beam with slp_trust. N beam segments and 2N design variables, taken from Vanderplaats (1984) Example 5-1, pp. 147-150.

This code is an applicatino of EMOO by using Genetic algorithms to solve the following simple constrained problem: Draw the biggest possible circle in a 2D space filled with stars without

Script to Run Gary Vanderplaats cantilever Beam with SQP and SLP. N beam segments and 2N design variables, taken from Vanderplaats (1984) Example 5-1, pp. 147-150.

AOE 5064 Homework #3, Problem 5a: SQP for Svanberg beam

Backward-compatible with Optimization Toolbox version 1.0

The purpose of this demo is to reconstruct a simple picture of several polygons. I start by generating 'numOfPolygons' polygons of random colors ( left upper corner in the figure), say it's

Constraints set

Ema's stick man is tall and has a top hat. What a gentleman.

Example problem taken from Vanderplaats textbook, example 3-1. Unconstrained potential energy minimization of two springs. Complex-step gradient.

First, the objective here is to find all of the negative real parts of the roots of a given polynomial with parameters. There is no restricition on the number of parameters, but for practical

Parameters of the Riemann problem

Constitutive law in 1D elastodynamics

We demonstrate routines of the PROMPT package by modeling conformational motion between two conformations of calmodulin. To launch the example, use the following command:

Differintegral of a tabular function using Fourier series representation

This function performs cumulative mathematics on 2D matrices at arbitrary angles. This function works by using the Image Processing Toolbox function imrotate to rotate an input matrix to

The Padé approximant often gives better approximation of the function than truncating its Taylor series, and it may still work where the Taylor series does not converge. For these reasons

This means no pennies. There are only 11 ways to do this.

Jana's stickgirl is running full speed with headphones.

All the scripts provided are used in Partial Differential Equation Methods for Image Inpainting (Carola-Bibiane Schoenlieb, Cambridge University Press, 2015):

This toolbox provides a basic MATLAB interface to CVXOPT's cone LP solver.

The code has been designed for calculate grade of students based on their performance in Mid semester Exam and End semester examination. The case has following highlight.

Customize the GraphPlot data cursor to display extra node properties of a graph.

This page contains two examples of solving nonstiff ordinary differential equations using ode45. MATLAB® has three solvers for nonstiff ODEs.

Construct and analyze a Watts-Strogatz small-world graph. The Watts-Strogatz model is a random graph that has small-world network properties, such as clustering and short average path

Write a simple event function for use with an ODE solver. The example file ballode models the motion of a bouncing ball. The events function halts the integration each time the ball bounces,

Use the directional components of an event function. The example file orbitode simulates a restricted three body problem where one body is orbiting two much larger bodies. The events

This page contains two examples of solving stiff ordinary differential equations using ode15s. MATLAB® has four solvers designed for stiff ODEs.

Fit a nonlinear function to data. For this example, the nonlinear function is the standard exponential decay curve

It is often useful to use a graphical format to view the distribution of the nonzero elements within a sparse matrix. The MATLAB spy function produces a template view of the sparsity

Split the integration domain to place a singularity on the boundary.

Plot the imaginary part versus the real part of a complex vector, z . With complex inputs, plot(z) is equivalent to plot(real(z),imag(z)) , where real(z) is the real part of z and imag(z) is the

You can use convolution to smooth 2-D data that contains high-frequency components.

The filter function is one way to implement a moving-average filter, which is a common data smoothing technique.

Integrate a set of discrete velocity data numerically to approximate the distance traveled. The integral family only accepts function handles as inputs, so those functions cannot be used

Use the Laplacian matrix of a graph to compute the Fiedler vector. The Fiedler vector can be used to partition the graph into two subgraphs.

The convhull and convhulln functions take a set of points and output the indices of the points that lie on the boundary of the convex hull. The point index-based representation of the convex

Interpolate scattered data when the value at each sample location is complex.

Perform nearest-neighbor interpolation on a scattered set of points using a specific Delaunay triangulation.

Modify the amplitude of a vector of data by applying a transfer function.

Calculate complex line integrals using the 'Waypoints' option of the integral function. In MATLAB®, you use the 'Waypoints' option to define a sequence of straight line paths from the first

Use the polyint function to integrate polynomial expressions analytically. Use this function to evaluate indefinite integral expressions of polynomials.

Add attributes to the nodes and edges in graphs created using graph and digraph . You can specify node names or edge weights when you originally call graph or digraph to create a graph. However,

Reduce the dimensionality of the grid plane arrays in 3-D to solve a 2-D interpolation problem.

The Voronoi diagram and the Delaunay triangulation on the same 2-D plot.

Fit data with a linear model containing nonpolynomial terms.

The alpha shape of a set of points is a generalization of the convex hull and a subgraph of the Delaunay triangulation. That is, the convex hull is just one type of alpha shape, and the full family

This topic shows how to constrain the solution of an ODE to be nonnegative. Imposing nonnegativity is not always trivial, but sometimes it is necessary due to the physical interpretation of

Interpolate three 1-D data sets in a single pass using griddedInterpolant . This is a faster alternative to looping over your data sets.

Interpolate two different samplings of the same parabolic function. It also shows that a better distribution of sample points produces better extrapolation results.

You can solve polynomial equations involving trigonometric functions by simplifying the equation using a substitution. The resulting polynomial of one variable no longer contains any

In optics, the Fourier transform can be used to describe the diffraction pattern produced by a plane wave incident on an optical mask with a small aperture [1]. This example uses the fft2

Represent a polynomial as a vector in MATLAB® and evaluate the polynomial at points of interest.

Extrapolate a well sampled 3-D gridded dataset using scatteredInterpolant . The query points lie on a planar grid that is completely outside domain.

Plot graphs, and then customize the display to add labels or highlighting to the graph nodes and edges.

Compute the convex hull of a 2-D point set using the alphaShape function.

Access and modify the nodes and/or edges in a graph or digraph object using the addedge , rmedge , addnode , rmnode , findedge , findnode , and subgraph functions.

Create and plot a 1-D interpolant using griddedInterpolant with a cubic interpolation method.

The Delaunay triangulation is well suited to scattered data interpolation problems because it has favorable geometric properties that produce good results. These properties are:

The convex hull of a set of points in N-D space is the smallest convex region enclosing all points in the set. If you think of a 2-D set of points as pegs in a peg board, the convex hull of that set

Perform linear interpolation on a scattered set of points with a specific Delaunay triangulation.

The relationship between a Delaunay triangulation of a set of points in 2-D and the convex hull of that set of points.

The Fourier transform is a mathematical formula that relates a signal sampled in time or space to the same signal sampled in frequency. In signal processing, the Fourier transform can reveal

Approximate gradients of a function by finite differences. It then shows how to plot a tangent plane to a point on the surface by using these approximated gradients.

Use multiple regression to model data that is a function of more than one predictor variable.

Use the fzero function to find the roots of a polynomial in a specific interval. Among other uses, this method is suitable if you plot the polynomial and want to know the value of a particular

Use the polyint and polyder functions to analytically integrate or differentiate any polynomial represented by a vector of coefficients.

Use scatteredInterpolant to interpolate a scattered sampling of the peaks function.

Create and plot a 2-D interpolant using griddedInterpolant .

Create a 3-D interpolant and evaluate over a slice plane so you can plot the values on that plane.

Use the rng function, which provides control over random number generation.

Basic techniques and functions for working with matrices in the MATLAB® language.

How the Fourier series expansion for a square wave is made up of a sum of odd harmonics.

An application of sparse matrices and explains the relationship between graphs and matrices.

You can use the Fourier transform to analyze variations in data, such as an event in nature over a period time.

Extrapolating data using polynomials of even modest degree is risky and unreliable.

An interesting graphical approach for discovering whether {\mathrm{e}}^{\pi } is greater than \pi^e .

Compute and represent the finite difference Laplacian on an L-shaped domain.

The finite element mesh for a NASA airfoil, including two trailing flaps. More information about the history of airfoils is available at NACA Airfoils (nasa.gov) .

Use griddedInterpolant to resample the pixels in an image. Resampling an image is useful for adjusting the resolution and size, and you also can use it to smooth out the pixels after zooming.

How reordering the rows and columns of a sparse matrix can influence the speed and storage requirements of a matrix operation.

The use of the FFT function for spectral analysis. A common use of FFT's is to find the frequency components of a signal buried in a noisy time domain signal.

Solve a differential equation representing a predator/prey model using both ode23 and ode45 . These functions are for the numerical solution of ordinary differential equations using

Use normalization to improve scattered data interpolation results with griddata . Normalization can improve the interpolation results in some cases, but in others it can compromise the

Create, edit, and query Delaunay triangulations using the delaunayTriangulation class. The Delaunay triangulation is the most widely used triangulation in scientific computing. The

3 of the 19 ways to compute the exponential of a matrix.

Use MATLAB® to formulate and solve several different types of differential equations. MATLAB offers several numerical algorithms to solve a wide variety of differential equations:

Use a PageRank algorithm to rank a collection of websites. Although the PageRank algorithm was originally designed to rank search engine results, it also can be more broadly applied to the

Working with missing data is a common task in data preprocessing. Although sometimes missing values signify a meaningful event in the data, they often represent unreliable or unusable data

Add and customize labels on graph nodes and edges.

You can use the Fourier transform to analyze the frequency spectrum of audio data.

The Fourier transform can compute the frequency components of a signal that is corrupted by random noise.

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