MATLAB Examples

Fit an exponential model to data using the fit function.

Fit and compare polynomials up to sixth degree using Curve Fitting Toolbox, fitting some census data. It also shows how to fit a single-term exponential equation and compare this to the

Use the fit function to fit polynomials to data. The steps fit and plot polynomial curves and a surface, specify fit options, return goodness of fit statistics, calculate predictions, and

Work with a curve fit.

Small, round blue-cell tumors (SRBCTs) belong to four distinct diagnostic categories. The categories have widely differing prognoses and treatment options, making it extremely

Use the fit function to fit a Fourier model to data.

Compare the effects of excluding outliers and robust fitting. The example shows how to exclude outliers at an arbitrary distance greater than 1.5 standard deviations from the model. The

Fit a custom equation to census data, specifying bounds, coefficients, and a problem-dependent parameter.

Demonstrates fitting a non-linear regression tree model to hourly day-ahead electricity prices in the New England pool region. The log electricity prices are modeled with two additive

Demo file from August 7, 2007 webinar titled Data Analysis with Statistics Toolbox and Curve Fitting Toolbox. View the recorded webinar:

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

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.

Goal - Produce a reliable med term forecasting model for Energy Demand

Work with a surface fit.

Find the first and second derivatives of a fit, and the integral of the fit, at the predictor values.

The Natural Gas Price model, Temperature model and Electricity Price hybrid model are jointly simulated to create market scenarios. Then, given a set of plant parameters and constraints a

Demonstrates calibrating an Ornstein-Uhlenbeck mean reverting stochastic model from historical data of natural gas prices. The model is then used to simulate the spot prices into the

Demonstrates fitting a non-linear temperature model to hourly dry bulb temperatures recorded in the New England region. The temperature series is modeled as a sum of two compoments, a

データは以下ページから取得したオープンデータを使用

This demo shows how to price a GMWB rider. Yi Wang, MathWorks, 2010

The aim of this demo is to characterize the "complete spectrum of interaction" between opiods and hypnotics, using propofol and remifentanil as drug class prototypes [1]. 4 different

In this example, we look at our efforts to characterize a device under test. We have this "black box" that we need to better understand. We might just want to know some of it's characteristics,

緯度

Center for Open Data in Humanities launched Japanese Classics Character Dataset in November 2016 [1]. This is a large dataset of various hand-written characters from classical documents

Teaches how to use the Metropolis algorithm to simulate the Ising model of a ferromagnet in MATLAB.

Copyright 2018 The MathWorks, Inc.

Kevin Chng

Define a custom mini-batch datastore that can be used to feed training data to a deep learning network. The custom mini-batch datastore, called vdsrImagePatchDatastore , is a convenient

Train a convolutional neural network on CIFAR-10 using MATLAB's built-in support for parallel training. Deep Learning training often takes hours or days. You can use parallel computing to

Send deep learning training batch jobs to a cluster so that you can continue working or close MATLAB during training. Training deep neural networks often takes a lot of time. This example

Use a parfor loop to perform a parameter sweep on a training option. Deep Learning training often takes hours or days, and searching for good training options can be difficult. You can use

Use parfeval for a parameter sweep on the depth of the network architecture. Deep Learning training often takes hours or days, and searching for good architectures can be difficult. You can

Upload your data to an Amazon S3 bucket. Before you can perform deep learning training in the cloud, you need to upload your data to the cloud. The example shows how to download the CIFAR-10 data

Visualize the features learned by convolutional neural networks.

Apply Bayesian optimization to deep learning and find optimal network parameters and training options for convolutional neural networks.

Define an output function that runs at each iteration during training of deep learning neural networks. If you specify output functions by using the 'OutputFcn' name-value pair argument of

Generate images using deepDreamImage with the pretrained convolutional neural network AlexNet.

Feed an image to a convolutional neural network and display the activations of different layers of the network. Examine the activations and discover which features the network learns by

Illustrates how a pattern recognition neural network can classify wines by winery based on its chemical characteristics.

Neurons in a competitive layer learn to represent different regions of the input space where input vectors occur.

Illustrates how a self-organizing map neural network can cluster iris flowers into classes topologically, providing insight into the types of flowers and a useful tool for further

Illustrates how to train a neural network to perform simple character recognition.

Illustrates how to design a linear neuron to predict the next value in a time series given the last five values.

Train stacked autoencoders to classify images of digits.

Fit a function to data using lsqcurvefit together with MultiStart .

Find the minimum of Rastrigin's function restricted so the first component of x is an integer. The components of x are further restricted to be in the region 5 \pi\le x(1) \le 20\pi,\ -20\pi\le

Optimize using the particleswarm solver. The particle swarm algorithm moves a population of particles called a swarm toward a minimum of an objective function. The velocity of each

Use an output function for particleswarm. The output function plots the range that the particles occupy in each dimension.

Optimize using the particleswarm solver.

How @gacreationlinearfeasible, the default creation function for linearly constrained problems, creates a population for ga. The population is well-dispersed, and is biased to lie on

Solve a mixed integer engineering design problem using the Genetic Algorithm (ga) solver in Global Optimization Toolbox.

The use of a custom output function in the genetic algorithm solver ga. The custom output function performs the following tasks:

Minimize an objective function subject to nonlinear inequality constraints and bounds using the Genetic Algorithm.

Use the genetic algorithm to minimize a function using a custom data type. The genetic algorithm is customized to solve the traveling salesman problem.

Create and manage options for the genetic algorithm function ga using optimoptions in the Global Optimization Toolbox.

Use a hybrid scheme to optimize a function using the Genetic Algorithm and another optimization method. ga can reach the region near an optimum point relatively quickly, but it can take many

Create and minimize a fitness function for the genetic algorithm solver ga using three techniques:

Create and minimize an objective function using Simulated Annealing in the Global Optimization Toolbox.

Create and manage options for the simulated annealing function simulannealbnd using optimoptions in the Global Optimization Toolbox.

Use simulated annealing to minimize a function using a custom data type. Here simulated annealing is customized to solve the multiprocessor scheduling problem.

Use the functions GlobalSearch and MultiStart.

Visually how pattern search optimizes a function. The function is the height of the terrain near Mount Washington, as a function of the x-y location. In order to find the top of Mount

Minimize an objective function subject to nonlinear inequality constraints and bounds using pattern search.

Create and manage options for the pattern search function patternsearch using the optimoptions function in the Global Optimization Toolbox.

Find a minimum of a stochastic objective function using patternsearch. It also shows how Optimization Toolbox™ solvers are not suitable for this type of problem. The example uses a simple

Create and minimize an objective function using Pattern Search in Global Optimization Toolbox.

The behavior of three recommended solvers on a minimization problem. The objective function is the multirosenbrock function:

Create an optimal design for a polynomial model using Model-Based Calibration Toolbox™ command-line interface.

Use the command-line functionality to generate local designs at each global operating point. This particular example shows how you can produce local maps for a diesel engine calibration.

Create and apply constraints to a design using Model-Based Calibration Toolbox™ command-line interface.

Design an experiment for the gasoline case study problem using the command-line interface to Model-Based Calibration Toolbox™. The gasoline case study describes how to systematically

Load and modify data using Model-Based Calibration Toolbox™ command-line interface. Data can be loaded from files (Excel® files, MATLAB® files, text files) and from the MATLAB®

Automatically generate an mbcmodel project for the gasoline case study using the command-line tools in Model-Based Calibration Toolbox™ .

Use the Model-Based Calibration Toolbox™ command-line functionality for point-by-point engine modeling projects.

We propose two fuzzy portfolio optimization models based on the Markowitz Mean-Variance approach. The first model involves trapezoidal fuzzy numbers to extent statistical data, which

Demonstrates optimizing a storage facility and valuing a storage contract using intrinsic valuation. The optimization involves finding the optimal positions in a set of forward natural

Revisit the optimal ITAE transfer function for step input using numerical optimization and digital computer.

Time series of acceleration records are simulated using a stationnary process that is "weighted" by an envelopp function. The function that fullfills this procedure is 'seismSim'.

The toolbox is designed to estimate the parameters of a regime switching copula model, assuming two regimes. Each regime can be described by any of the following five copulas:

Solve portfolio optimization problems using the problem-based approach. For the solver-based approach, see docid:optim_ug.mw_77a68b16-ab47-4689-adc9-5e72ead3ea3a.

Determine the shape of a circus tent by solving a quadratic optimization problem. The tent is formed from heavy, elastic material, and settles into a shape that has minimum potential energy

The value of using sparse arithmetic when you have a sparse problem. The matrix has n rows, where you choose n to be a large value, and a few nonzero diagonal bands. A full matrix of size n -by- n can

Solve portfolio optimization problems using the interior-point quadratic programming algorithm in quadprog. The function quadprog belongs to Optimization Toolbox™.

Formulate and solve a scalable bound-constrained problem with a quadratic objective function. The example shows the solution behavior using several algorithms. The problem can have any

Perform nonlinear fitting of complex-valued data. While most Optimization Toolbox™ solvers and algorithms operate only on real-valued data, least-squares solvers and fsolve can work on

Recover a blurred image by solving a large-scale bound-constrained linear least-squares optimization problem. The example uses the problem-based approach. For the solver-based

Fit parameters of an ODE to data in two ways. The first shows a straightforward fit of a constant-speed circular path to a portion of a solution of the Lorenz system, a famous ODE with sensitive

Problem-based approaches for solving the problem

Recover a blurred image by solving a large-scale bound-constrained linear least-squares optimization problem. The example uses the solver-based approach. For the problem-based

Formulate a linear least squares problem using the problem-based approach.

How to speed up the minimization of an expensive optimization problem using functions in Optimization Toolbox™ and Global Optimization Toolbox. In the first part of the example we solve the

Solve a nonlinear filter design problem using a minimax optimization algorithm, fminimax , in Optimization Toolbox™. Note that to run this example you must have the Signal Processing

Minimize Rosenbrock's "banana function":

Use semi-infinite programming to investigate the effect of uncertainty in the model parameters of an optimization problem. We will formulate and solve an optimization problem using the

Use the Symbolic Math Toolbox™ functions jacobian and matlabFunction to provide analytical derivatives to optimization solvers. Optimization Toolbox™ solvers are usually more

This examples conducts a parametric study in which heat conduction simulation is performed over a set of similar geometries to determine which geometry "best" meets an average temperature

Analyze an idealized 3-D mechanical part under an applied loading using Finite Element Analysis (FEA). The objective of the analysis is to determine the maximum deflection caused by the

Calculate the deflection of a structural plate acted on by a pressure loading using the Partial Differential Equation Toolbox™.

Numerically solve a Poisson's equation, compare the numerical solution with the exact solution, and refine the mesh until the solutions are close.

Calculate the deflection of a structural plate acted on by a pressure loading.

Solve the heat equation with a source term.

Analyze a 3-D axisymmetric model by using a 2-D model.

Solve a Poisson's equation with a delta-function point source on the unit disk using the adaptmesh function.

Solve a coupled elasticity-electrostatics problem.

Perform a heat transfer analysis of a thin plate.

Calculate the vibration modes and frequencies of a 3-D simply supported, square, elastic plate.

Analyze the dynamic behavior of a beam clamped at both ends and loaded with a uniform pressure load.

Solve a Helmholtz equation using the solvepde function.

Calculate the vibration modes of a circular membrane by using the MATLAB eigs function.

Calculate eigenvalues and eigenvectors using the programmatic workflow. For the PDE Modeler app solution, see Eigenvalues and Eigenmodes of the L-Shaped Membrane: PDE App .

Compute the eigenvalues and eigenmodes of a square domain using the programmatic workflow. For the PDE Modeler app solution, see Eigenvalues and Eigenmodes of a Square .

Solve for the heat distribution in a block with cavity using the programmatic workflow. For the PDE Modeler app solution, see Heat Equation for a Block with Cavity: PDE App .

Perform modal and transient analysis of a tuning fork.

Perform a 2-D plane-stress elasticity analysis.

Solve a coupled thermo-elasticity problem. Thermal expansion or contraction in mechanical components and structures occurs due to temperature changes in the operating environment.

Analyze a 3-D mechanical part under an applied load using finite element analysis (FEA) and determine the maximal deflection.

Create a cardioid geometry using four distinct techniques. The techniques are ways to parametrize your geometry using arc length calculations. The cardioid satisfies the equation .

Use anovan to fit models where a factor's levels represent a random selection from a larger (infinite) set of possible levels.

In this example, use a database of 1985 car imports with 205 observations, 25 predictors, and 1 response, which is insurance risk rating, or "symboling." The first 15 variables are numeric

Generate a nonlinear classifier with Gaussian kernel function. First, generate one class of points inside the unit disk in two dimensions, and another class of points in the annulus from

Compute and plot the pdf of a Poisson distribution with parameter lambda = 5 .

Use Cook's Distance to determine the outliers in the data.

Perform linear and quadratic classification of Fisher iris data.

Use copulafit to calibrate copulas with data. To generate data Xsim with a distribution "just like" (in terms of marginal distributions and correlations) the distribution of data in the

Similar to the bootstrap is the jackknife, which uses resampling to estimate the bias of a sample statistic. Sometimes it is also used to estimate standard error of the sample statistic. The

Find the indices of the three nearest observations in X to each observation in Y with respect to the chi-square distance. This distance metric is used in correspondence analysis,

Create a classification tree ensemble for the ionosphere data set, and use it to predict the classification of a radar return with average measurements.

Perform N-way ANOVA on car data with mileage and other information on 406 cars made between 1970 and 1982.

Plot the pdf of a bivariate Student's t distribution. You can use this distribution for a higher number of dimensions as well, although visualization is not easy.

Compute and plot the pdf using four different values for the parameter r , the desired number of successes: .1 , 1 , 3 , and 6 . In each case, the probability of success p is .5 .

Use a random subspace ensemble to increase the accuracy of classification. It also shows how to use cross validation to determine good parameters for both the weak learner template and the

As for all discrete distributions, the cdf is a step function. The plot shows the discrete uniform cdf for N = 10.

You can also use ensembles of decision trees for classification. For this example, use ionosphere data with 351 observations and 34 real-valued predictors. The response variable is

Test for the significance of the regression coefficients using t-statistic.

Use cmdscale to perform classical (metric) multidimensional scaling, also known as principal coordinates analysis.

When you have missing data, trees and ensembles of trees give better predictions when they include surrogate splits. Furthermore, estimates of predictor importance are often different

Compute and plot the pdf of a multivariate normal distribution.

Load the sample data.

Display R-squared (coefficient of determination) and adjusted R-squared. Load the sample data and define the response and independent variables.

The bootstrap procedure involves choosing random samples with replacement from a data set and analyzing each sample the same way. Sampling with replacement means that each observation is

This example was authored by the MathWorks community.

INTRODUCTION

Basic physics courses at our universities are filled with a considerable amount of content, especially since the transition from Diploma to Bachelor's degree programs. They promote

A first step to theoretical physics is the mathematical description of space and time. This is based on coordinate systems consisting of an origin, basis vectors and coordinates.

We consider spherical coordinates \[\vec r = \left( {\begin{array}{*{20}{c}} {r\sin \theta \cos \varphi } \\ {r\sin \theta \sin \varphi } \\ {r\cos \theta } \end{array}} \right)\]

We parameterize a Mexican hat by

Instead of coordinates of lines points, movements of the pen are specified. There are commands for forward movement, rotation, color and storage of states:

Man unterscheidet grundsätzlich zwei Arten von chaotischen Systemen

In contrast to water waves or sound waves, for light signals there is no medium to which the velocity of the signals can relate. There is only the observer, and nothing else. Light signals

We consider the dynamics of the Kepler problem

Trajectories

The quantum-mechanical double-slit experiment

There are basically two types of chaotic systems

The Duffing oscillator is a one-dimensional driven oscillator with friction and a nonlinear potential. It is described by the

Die HJG drückt den Energisatz durch die Wirkung S aus und hat damit eine klare physikalische Bedeutung:

Es gibt verschiedene Möglichkeiten zur Beschreibung von Wechselwirkung (WW).

Der Duffing-Oszillator ist ein eindimensionaler, angetriebener Oszillator mit Reibung und einem nichtlinearen Potenzial. Er wird beschrieben durch die

For the formulation of classical mechanics, Isaac Newton distinguished sharply between content and dynamics. His dynamic laws apply in general, regardless of any content. They are then

The suspension point {K_1} of a plane pendulum slides frictionless along the x-axis. The pendulum body {K_2} has the distance L from the suspension point. Both bodies have the same mass

Author: Anna Sibilska-Mroziewicz

With the Lorentz transformation, world points and world lines are transformed between coordinate systems with constant relative velocity. This can be used to study the twin paradox of the

A Gaussian wave packet is formed by the superposition of plane waves g_p with a Gaussian momentum distribution f(p) (see below).

Analyze text using n-gram frequency counts.

Decide on a suitable number of topics for a latent Dirichlet allocation (LDA) model.

Compare latent Dirichlet allocation (LDA) solvers by comparing the goodness of fit and the time taken to fit the model.

Train a classifier for sentiment analysis using an annotated list of positive and negative sentiment words and a pretrained word embedding.

Extract the text data from text, HTML, Microsoft® Word, PDF, CSV, and Microsoft Excel® files and import it into MATLAB® for analysis.

Parse HTML code and extract the text content from particular elements.

Analyze text data containing emojis.

Import, prepare, and analyze Japanese text data using a topic model.

Use the Latent Dirichlet Allocation (LDA) topic model to analyze text data.

Create a function which cleans and preprocesses text data for analysis.

Train a simple text classifier on word frequency counts using a bag-of-words model.

Visualize text data using word clouds.

Visualize word embeddings using 2-D and 3-D t-SNE and text scatter plots.

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